Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | 20 | public function transform(ResponseInterface $response): array |
|
23 | { |
||
24 | 20 | $body = (string) $response->getBody(); |
|
25 | 20 | if (strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) { |
|
26 | 19 | $content = json_decode($body, true); |
|
27 | 19 | if (JSON_ERROR_NONE === json_last_error()) { |
|
28 | 18 | return $content; |
|
29 | } |
||
30 | |||
31 | 1 | throw new TransformResponseException('Error transforming response to array. JSON_ERROR: ' |
|
32 | 1 | . json_last_error()); |
|
33 | } |
||
34 | |||
35 | 1 | throw new TransformResponseException('Error transforming response to array. Content-Type |
|
36 | is not application/json'); |
||
39 |