functions.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Assert
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * If you did not receive a copy of the license and are unable to
  10. * obtain it through the world-wide-web, please send an email
  11. * to kontakt@beberlei.de so I can send you a copy immediately.
  12. */
  13. namespace Assert;
  14. /**
  15. * Start validation on a value, returns {@link AssertionChain}.
  16. *
  17. * The invocation of this method starts an assertion chain
  18. * that is happening on the passed value.
  19. *
  20. * @param mixed $value
  21. * @param string|callable|null $defaultMessage
  22. * @param string $defaultPropertyPath
  23. *
  24. * @example
  25. *
  26. * \Assert\that($value)->notEmpty()->integer();
  27. * \Assert\that($value)->nullOr()->string()->startsWith("Foo");
  28. *
  29. * The assertion chain can be stateful, that means be careful when you reuse
  30. * it. You should never pass around the chain.
  31. */
  32. function that($value, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
  33. {
  34. return Assert::that($value, $defaultMessage, $defaultPropertyPath);
  35. }
  36. /**
  37. * Start validation on a set of values, returns {@link AssertionChain}.
  38. *
  39. * @param mixed $values
  40. * @param string|callable|null $defaultMessage
  41. * @param string $defaultPropertyPath
  42. */
  43. function thatAll($values, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
  44. {
  45. return Assert::thatAll($values, $defaultMessage, $defaultPropertyPath);
  46. }
  47. /**
  48. * Start validation and allow NULL, returns {@link AssertionChain}.
  49. *
  50. * @param mixed $value
  51. * @param string|callable|null $defaultMessage
  52. * @param string $defaultPropertyPath
  53. *
  54. * @deprecated In favour of Assert::thatNullOr($value, $defaultMessage = null, $defaultPropertyPath = null)
  55. */
  56. function thatNullOr($value, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
  57. {
  58. return Assert::thatNullOr($value, $defaultMessage, $defaultPropertyPath);
  59. }
  60. /**
  61. * Create a lazy assertion object.
  62. */
  63. function lazy(): LazyAssertion
  64. {
  65. return Assert::lazy();
  66. }