| Conditions | 5 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | public function normalize($exception, $format = null, array $context = []): array |
||
| 21 | { |
||
| 22 | $formattedErrors = []; |
||
| 23 | |||
| 24 | foreach ($exception->getErrors() as $error) { |
||
| 25 | $cause = $error->getCause(); |
||
| 26 | |||
| 27 | if ($cause && method_exists($cause, 'getPropertyPath') && $cause->getPropertyPath()) { |
||
| 28 | $path = preg_replace('/^(data.)|(.data)|(\\])|(\\[)|children/', '', $cause->getPropertyPath()); |
||
| 29 | $formattedErrors[$path] = $error->getMessage(); |
||
| 30 | } else { |
||
| 31 | $formattedErrors[] = $error->getMessage(); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | return $formattedErrors; |
||
| 36 | } |
||
| 43 |