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