Conditions | 5 |
Paths | 9 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
32 | protected function guardResult(Result $result, ?ValidationExceptionInterface $validationException = null): void |
||
33 | { |
||
34 | if ($result->isOk()) { |
||
35 | return; |
||
36 | } |
||
37 | |||
38 | $exception = |
||
39 | $validationException instanceof ValidationExceptionInterface ? |
||
40 | $validationException : |
||
41 | new ValidationException(); |
||
42 | |||
43 | $field = $result instanceof ResultByField ? $result->getField() : null; |
||
44 | foreach ($result->getErrors() as $error) { |
||
45 | $exception->addError($error, $field); |
||
46 | } |
||
47 | |||
48 | throw $exception; |
||
49 | } |
||
51 |