Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4.0119 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
28 | 10 | protected function validateValue($value, ?ValidationContext $context = null): Result |
|
29 | { |
||
30 | 10 | $callback = $this->callback; |
|
31 | 10 | $callbackResult = $callback($value, $context); |
|
32 | |||
33 | 10 | if (!$callbackResult instanceof Result) { |
|
34 | 1 | throw new InvalidCallbackReturnTypeException($callbackResult); |
|
35 | } |
||
36 | |||
37 | 9 | $result = new Result(); |
|
38 | 9 | if ($callbackResult->isValid()) { |
|
39 | return $result; |
||
40 | } |
||
41 | |||
42 | 9 | foreach ($callbackResult->getErrors() as $error) { |
|
43 | 9 | $result->addError($this->formatMessage($error->getMessage()), $error->getValuePath()); |
|
44 | } |
||
45 | |||
46 | 9 | return $result; |
|
47 | } |
||
49 |