Conditions | 1 |
Paths | 1 |
Total Lines | 14 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | public function getErrorResponse(ConstraintViolationListInterface $errors) |
||
18 | { |
||
19 | $propertyAccessor = PropertyAccess::createPropertyAccessor(); |
||
20 | |||
21 | return new JsonResponse([ |
||
22 | 'message' => 'Please check your data', |
||
23 | 'errors' => array_map(function (ConstraintViolation $violation) use ($propertyAccessor) { |
||
24 | return [ |
||
25 | 'path' => $violation->getPropertyPath(), |
||
26 | 'message' => $violation->getMessage(), |
||
27 | ]; |
||
28 | }, iterator_to_array($errors)), |
||
29 | ], 400); |
||
30 | } |
||
31 | } |