| Conditions | 5 |
| Paths | 5 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 15 | public function validate($input, Constraint $constraint): void |
||
| 16 | { |
||
| 17 | if (!$constraint instanceof FieldName) { |
||
| 18 | throw new Exception\UnexpectedTypeException($constraint, FieldName::class); // @codeCoverageIgnore |
||
| 19 | } |
||
| 20 | |||
| 21 | if (!$input instanceof InputInterface) { |
||
| 22 | throw new Exception\UnexpectedTypeException($input, InputInterface::class); // @codeCoverageIgnore |
||
| 23 | } |
||
| 24 | |||
| 25 | foreach ($this->getFields($input) as $fieldName) { |
||
| 26 | if (!\preg_match($constraint->pattern, $fieldName)) { |
||
| 27 | $this->context |
||
| 28 | ->buildViolation($constraint->message) |
||
| 29 | ->atPath($fieldName) |
||
| 30 | ->setParameter('{{ field }}', $fieldName) |
||
| 31 | ->addViolation(); |
||
| 32 | } |
||
| 49 |