Command
2 years ago
Constraints
1 year ago
Context
1 year ago
Exception
3 years ago
Mapping
6 months ago
Util
3 years ago
Validator
8 months ago
Violation
3 years ago
Constraint.php
1 year ago
ConstraintValidator.php
2 years ago
ConstraintValidatorFactory.php
4 years ago
ConstraintValidatorFactoryInterface.php
4 years ago
ConstraintValidatorInterface.php
4 years ago
ConstraintViolation.php
1 year ago
ConstraintViolationInterface.php
4 years ago
ConstraintViolationList.php
4 years ago
ConstraintViolationListInterface.php
4 years ago
ContainerConstraintValidatorFactory.php
4 years ago
GroupSequenceProviderInterface.php
4 years ago
ObjectInitializerInterface.php
4 years ago
Validation.php
4 years ago
ValidatorBuilder.php
4 years ago
index.php
3 years ago
ConstraintViolation.php
91 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\Validator; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | class ConstraintViolation implements ConstraintViolationInterface |
| 5 | { |
| 6 | private $message; |
| 7 | private $messageTemplate; |
| 8 | private $parameters; |
| 9 | private $plural; |
| 10 | private $root; |
| 11 | private $propertyPath; |
| 12 | private $invalidValue; |
| 13 | private $constraint; |
| 14 | private $code; |
| 15 | private $cause; |
| 16 | public function __construct($message, ?string $messageTemplate, array $parameters, $root, ?string $propertyPath, $invalidValue, ?int $plural = null, ?string $code = null, ?Constraint $constraint = null, $cause = null) |
| 17 | { |
| 18 | if (!\is_string($message) && !(\is_object($message) && \method_exists($message, '__toString'))) { |
| 19 | throw new \TypeError('Constraint violation message should be a string or an object which implements the __toString() method.'); |
| 20 | } |
| 21 | $this->message = $message; |
| 22 | $this->messageTemplate = $messageTemplate; |
| 23 | $this->parameters = $parameters; |
| 24 | $this->plural = $plural; |
| 25 | $this->root = $root; |
| 26 | $this->propertyPath = $propertyPath; |
| 27 | $this->invalidValue = $invalidValue; |
| 28 | $this->constraint = $constraint; |
| 29 | $this->code = $code; |
| 30 | $this->cause = $cause; |
| 31 | } |
| 32 | public function __toString() |
| 33 | { |
| 34 | if (\is_object($this->root)) { |
| 35 | $class = 'Object(' . \get_class($this->root) . ')'; |
| 36 | } elseif (\is_array($this->root)) { |
| 37 | $class = 'Array'; |
| 38 | } else { |
| 39 | $class = (string) $this->root; |
| 40 | } |
| 41 | $propertyPath = (string) $this->propertyPath; |
| 42 | if ('' !== $propertyPath && '[' !== $propertyPath[0] && '' !== $class) { |
| 43 | $class .= '.'; |
| 44 | } |
| 45 | if (null !== ($code = $this->code) && '' !== $code) { |
| 46 | $code = ' (code ' . $code . ')'; |
| 47 | } |
| 48 | return $class . $propertyPath . ":\n " . $this->getMessage() . $code; |
| 49 | } |
| 50 | public function getMessageTemplate() |
| 51 | { |
| 52 | return (string) $this->messageTemplate; |
| 53 | } |
| 54 | public function getParameters() |
| 55 | { |
| 56 | return $this->parameters; |
| 57 | } |
| 58 | public function getPlural() |
| 59 | { |
| 60 | return $this->plural; |
| 61 | } |
| 62 | public function getMessage() |
| 63 | { |
| 64 | return $this->message; |
| 65 | } |
| 66 | public function getRoot() |
| 67 | { |
| 68 | return $this->root; |
| 69 | } |
| 70 | public function getPropertyPath() |
| 71 | { |
| 72 | return (string) $this->propertyPath; |
| 73 | } |
| 74 | public function getInvalidValue() |
| 75 | { |
| 76 | return $this->invalidValue; |
| 77 | } |
| 78 | public function getConstraint() |
| 79 | { |
| 80 | return $this->constraint; |
| 81 | } |
| 82 | public function getCause() |
| 83 | { |
| 84 | return $this->cause; |
| 85 | } |
| 86 | public function getCode() |
| 87 | { |
| 88 | return $this->code; |
| 89 | } |
| 90 | } |
| 91 |