| Conditions | 2 |
| Paths | 2 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | 26 | public function __invoke( |
|
| 22 | string $dataObjectName, |
||
| 23 | InputFilterInterface $inputFilter, |
||
| 24 | $value = null |
||
| 25 | ): ResponseInterface { |
||
| 26 | 26 | $validation = []; |
|
| 27 | 26 | foreach ($inputFilter->getInvalidInput() as $key => $input) { |
|
| 28 | 26 | $messages = $input->getMessages(); |
|
| 29 | 26 | $validation[] = [ |
|
| 30 | 26 | 'field' => $key, |
|
| 31 | 26 | 'msg' => reset($messages) |
|
| 32 | ]; |
||
| 33 | } |
||
| 34 | |||
| 35 | 26 | return new JsonResponse([ |
|
| 36 | 'data' => [ |
||
| 37 | 26 | $dataObjectName => $value, |
|
| 38 | 26 | 'validation' => $validation, |
|
| 39 | ], |
||
| 40 | 26 | 'msg' => new DangerMessage('There were validation errors.'), |
|
| 41 | 26 | ], 400); |
|
| 42 | } |
||
| 43 | } |
||
| 44 |