Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | 7 | public function validate(mixed $value, object $rule, ValidatorInterface $validator, ?ValidationContext $context = null): Result |
|
16 | { |
||
17 | 7 | $callback = $rule->callback; |
|
18 | 7 | $callbackResult = $callback($value, $context); |
|
19 | |||
20 | 7 | if (!$callbackResult instanceof Result) { |
|
21 | 1 | throw new InvalidCallbackReturnTypeException($callbackResult); |
|
22 | } |
||
23 | |||
24 | 6 | $result = new Result(); |
|
25 | 6 | if ($callbackResult->isValid()) { |
|
26 | 1 | return $result; |
|
27 | } |
||
28 | |||
29 | 5 | foreach ($callbackResult->getErrors() as $error) { |
|
30 | 5 | $result->merge($error); |
|
31 | } |
||
32 | |||
33 | 5 | return $result; |
|
34 | } |
||
36 |