InvalidArgumentException.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. class InvalidArgumentException extends \InvalidArgumentException implements AssertionFailedException
  15. {
  16. private $propertyPath;
  17. private $value;
  18. private $constraints;
  19. public function __construct($message, $code, $propertyPath, $value, array $constraints = array())
  20. {
  21. parent::__construct($message, $code);
  22. $this->propertyPath = $propertyPath;
  23. $this->value = $value;
  24. $this->constraints = $constraints;
  25. }
  26. /**
  27. * User controlled way to define a sub-property causing
  28. * the failure of a currently asserted objects.
  29. *
  30. * Useful to transport information about the nature of the error
  31. * back to higher layers.
  32. *
  33. * @return string
  34. */
  35. public function getPropertyPath()
  36. {
  37. return $this->propertyPath;
  38. }
  39. /**
  40. * Get the value that caused the assertion to fail.
  41. *
  42. * @return mixed
  43. */
  44. public function getValue()
  45. {
  46. return $this->value;
  47. }
  48. /**
  49. * Get the constraints that applied to the failed assertion.
  50. *
  51. * @return array
  52. */
  53. public function getConstraints()
  54. {
  55. return $this->constraints;
  56. }
  57. }