| Conditions | 5 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | protected function guardResult( |
||
| 28 | Result $result, |
||
| 29 | ValidationExceptionFactoryInterface | ValidationExceptionInterface | string | null $validationException = null |
||
| 30 | ): void { |
||
| 31 | if ($result->isOk()) { |
||
| 32 | return; |
||
| 33 | } |
||
| 34 | |||
| 35 | if ($validationException instanceof ValidationExceptionInterface) { |
||
| 36 | throw $validationException; |
||
| 37 | } |
||
| 38 | |||
| 39 | if ($validationException instanceof ValidationExceptionFactoryInterface) { |
||
| 40 | throw $validationException->create($result); |
||
| 41 | } |
||
| 42 | |||
| 43 | $exceptionMessage = $validationException; |
||
| 44 | if (ValidationException::hasFactory()) { |
||
| 45 | throw ValidationException::getFactory()->create($result, $exceptionMessage); |
||
| 46 | } |
||
| 47 | |||
| 48 | throw new ValidationException($result->getErrors(), $exceptionMessage); |
||
| 49 | } |
||
| 51 |