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