| Conditions | 5 |
| Paths | 2 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5.0187 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | 5 | public function __construct($errorData) |
|
| 17 | { |
||
| 18 | /** @var string[] $errors */ |
||
| 19 | 5 | $errors = []; |
|
| 20 | |||
| 21 | 5 | if ($errorData instanceof FormInterface) { |
|
| 22 | /** @var FormError $error */ |
||
| 23 | 5 | foreach ($errorData->getErrors(true) as $error) { |
|
| 24 | 5 | $parametersString = join(',', $error->getMessageParameters()); |
|
| 25 | 5 | if (!$parametersString || in_array($parametersString, ['null', 'array'])) { |
|
| 26 | 5 | $errors[] = $error->getMessage(); |
|
| 27 | } else { |
||
| 28 | 5 | $errors[] = sprintf('%s - %s', $parametersString, $error->getMessage()); |
|
| 29 | } |
||
| 30 | } |
||
| 31 | } else { |
||
| 32 | $errors = (array) $errorData; |
||
| 33 | } |
||
| 34 | |||
| 35 | 5 | parent::__construct($errors, Response::HTTP_BAD_REQUEST); |
|
| 36 | 5 | } |
|
| 37 | } |
||
| 38 |