| Conditions | 4 |
| Paths | 6 |
| Total Lines | 23 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function validate($value, Constraint $constraint) |
||
| 22 | { |
||
| 23 | if (null === $value) { |
||
| 24 | return; |
||
| 25 | } |
||
| 26 | try { |
||
| 27 | $valid = ClassNameValidator::validate($value, $this->formHandlers); |
||
| 28 | if (!$valid) { |
||
| 29 | $conditionsStr = vsprintf(' It should implement %s or tagged %s', [ |
||
| 30 | FormHandlerInterface::class, |
||
| 31 | 'silverback_api_component.form_handler' |
||
| 32 | ]); |
||
| 33 | $this->context |
||
| 34 | ->buildViolation($constraint->message . $conditionsStr) |
||
| 35 | ->setParameter('{{ string }}', $value) |
||
| 36 | ->addViolation() |
||
| 37 | ; |
||
| 38 | } |
||
| 39 | } catch (InvalidArgumentException $exception) { |
||
| 40 | $this->context |
||
| 41 | ->buildViolation($constraint->message . ' ' . $exception->getMessage()) |
||
| 42 | ->setParameter('{{ string }}', $value) |
||
| 43 | ->addViolation() |
||
| 44 | ; |
||
| 48 |