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