| Conditions | 3 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 2 |
| 1 | <?php |
||
| 25 | public function validate(HttpInputValidator $validator, Data &$input = null): ?Response |
||
| 26 | { |
||
| 27 | $input = new Immutable($this->getParsedBody() ?? []); |
||
|
|
|||
| 28 | if (0 === $input->count()) { |
||
| 29 | $errors = ['validate' => 'Nothing to validate', 'code' => StatusCode::BAD_REQUEST]; |
||
| 30 | return new ServerResponse(json_serialize($errors), StatusCode::BAD_REQUEST); |
||
| 31 | } |
||
| 32 | if (empty($errors = $validator->validate($input))) { |
||
| 33 | return null; |
||
| 34 | } |
||
| 35 | $errors['code'] = (int)($errors['code'] ?? StatusCode::BAD_REQUEST); |
||
| 36 | return new ServerResponse(json_serialize($errors), $errors['code']); |
||
| 37 | } |
||
| 39 |