| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | 54 | public function parse($data): ErrorCollection |
|
| 32 | { |
||
| 33 | 54 | if (!is_array($data)) { |
|
| 34 | 36 | throw new ValidationException(sprintf('ErrorCollection has to be in an array, "%s" given.', gettype($data))); |
|
| 35 | } |
||
| 36 | 18 | if (count($data) === 0) { |
|
| 37 | 6 | throw new ValidationException('ErrorCollection cannot be empty and MUST have at least one Error object.'); |
|
| 38 | } |
||
| 39 | |||
| 40 | 12 | return new ErrorCollection( |
|
| 41 | 12 | array_map( |
|
| 42 | 4 | function ($error) { |
|
| 43 | 12 | return $this->errorParser->parse($error); |
|
| 44 | 12 | }, |
|
| 45 | 10 | $data |
|
| 46 | ) |
||
| 50 |