| Conditions | 3 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 3 | ||
| Bugs | 0 | Features | 2 |
| 1 | <?php |
||
| 24 | 4 | public function validate(HttpInputValidator $validator): ?Response |
|
| 25 | { |
||
| 26 | 4 | $body = new Immutable($this->getParsedBody() ?? []); |
|
|
|
|||
| 27 | |||
| 28 | 4 | if (0 === $body->count()) { |
|
| 29 | 1 | return null; |
|
| 30 | } |
||
| 31 | |||
| 32 | 3 | if (empty($errors = $validator->validate($body))) { |
|
| 33 | 1 | return null; |
|
| 34 | } |
||
| 35 | |||
| 36 | 2 | $errors['code'] = (int)($errors['code'] ?? StatusCode::BAD_REQUEST); |
|
| 37 | 2 | return new ServerResponse(json_serialize($errors), $errors['code']); |
|
| 38 | } |
||
| 40 |