functions.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. * @example
  21. *
  22. * \Assert\that($value)->notEmpty()->integer();
  23. * \Assert\that($value)->nullOr()->string()->startsWith("Foo");
  24. *
  25. * The assertion chain can be stateful, that means be careful when you reuse
  26. * it. You should never pass around the chain.
  27. *
  28. * @param mixed $value
  29. * @param string $defaultMessage
  30. * @param string $defaultPropertyPath
  31. *
  32. * @return \Assert\AssertionChain
  33. */
  34. function that($value, $defaultMessage = null, $defaultPropertyPath = null)
  35. {
  36. return Assert::that($value, $defaultMessage, $defaultPropertyPath);
  37. }
  38. /**
  39. * Start validation on a set of values, returns {@link AssertionChain}.
  40. *
  41. * @param mixed $values
  42. * @param string $defaultMessage
  43. * @param string $defaultPropertyPath
  44. *
  45. * @return \Assert\AssertionChain
  46. */
  47. function thatAll($values, $defaultMessage = null, $defaultPropertyPath = null)
  48. {
  49. return Assert::thatAll($values, $defaultMessage, $defaultPropertyPath);
  50. }
  51. /**
  52. * Start validation and allow NULL, returns {@link AssertionChain}.
  53. *
  54. * @param mixed $value
  55. * @param string $defaultMessage
  56. * @param string $defaultPropertyPath
  57. *
  58. * @return \Assert\AssertionChain
  59. *
  60. * @deprecated In favour of Assert::thatNullOr($value, $defaultMessage = null, $defaultPropertyPath = null)
  61. */
  62. function thatNullOr($value, $defaultMessage = null, $defaultPropertyPath = null)
  63. {
  64. return Assert::thatNullOr($value, $defaultMessage, $defaultPropertyPath);
  65. }
  66. /**
  67. * Create a lazy assertion object.
  68. *
  69. * @return \Assert\LazyAssertion
  70. */
  71. function lazy()
  72. {
  73. return Assert::lazy();
  74. }