Conditions | 4 |
Paths | 6 |
Total Lines | 25 |
Code Lines | 18 |
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( |
||
30 | ' It should implement %s or tagged %s', |
||
31 | [ |
||
32 | FormHandlerInterface::class, |
||
33 | 'silverback_api_component.form_handler' |
||
34 | ] |
||
35 | ); |
||
36 | $this->context |
||
37 | ->buildViolation($constraint->message . $conditionsStr) |
||
38 | ->setParameter('{{ string }}', $value) |
||
39 | ->addViolation(); |
||
40 | } |
||
41 | } catch (InvalidArgumentException $exception) { |
||
42 | $this->context |
||
43 | ->buildViolation($constraint->message . ' ' . $exception->getMessage()) |
||
44 | ->setParameter('{{ string }}', $value) |
||
45 | ->addViolation(); |
||
46 | } |
||
49 |