Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
25 | 36 | public function parse($data): ErrorCollection |
|
26 | { |
||
27 | 36 | if (! is_array($data)) { |
|
28 | 24 | throw new ValidationException(sprintf('ErrorCollection MUST be an array, "%s" given.', gettype($data))); |
|
29 | } |
||
30 | 12 | if (count($data) === 0) { |
|
31 | 4 | throw new ValidationException('ErrorCollection cannot be empty and MUST have at least one Error object.'); |
|
32 | } |
||
33 | |||
34 | 8 | return new ErrorCollection( |
|
35 | 8 | array_map( |
|
|
|||
36 | 8 | fn ($error) => $this->errorParser->parse($error), |
|
37 | 4 | $data |
|
38 | 4 | ) |
|
42 |