Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
23 | 15 | public function validate(ResponseInterface $response): ValidationResultInterface |
|
24 | { |
||
25 | 15 | if (!$response instanceof JsonApiResponse) { |
|
26 | 3 | return new ValidationResult(ValidationResult::STATUS_ERROR); |
|
27 | } |
||
28 | 12 | if ($this->code !== $response->getCode()) { |
|
29 | 3 | return new ValidationResult(ValidationResult::STATUS_ERROR, ['Response code doesn\'t match']); |
|
30 | } |
||
31 | |||
32 | 9 | $value = json_decode(json_encode($response->getPayload())); |
|
33 | |||
34 | 9 | $schemaValidator = new JsonSchemaValidator(); |
|
35 | 9 | return $schemaValidator->validate($value, $this->schema); |
|
36 | } |
||
37 | |||
43 |