| 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 |
||
| 26 | 7 | protected function validateValue($value, ValidationContext $context = null): Result |
|
| 27 | { |
||
| 28 | 7 | $callback = $this->callback; |
|
| 29 | 7 | $callbackResult = $callback($value, $context); |
|
| 30 | |||
| 31 | 7 | if (!$callbackResult instanceof Result) { |
|
| 32 | 1 | throw new InvalidCallbackReturnTypeException($callbackResult); |
|
| 33 | } |
||
| 34 | |||
| 35 | 6 | $result = new Result(); |
|
| 36 | 6 | if ($callbackResult->isValid()) { |
|
| 37 | return $result; |
||
| 38 | } |
||
| 39 | |||
| 40 | 6 | foreach ($callbackResult->getErrorObjects() as $error) { |
|
| 41 | 6 | $result->addError($this->formatMessage($error->getMessage()), $error->getValuePath()); |
|
| 42 | } |
||
| 43 | |||
| 44 | 6 | return $result; |
|
| 45 | } |
||
| 47 |