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