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