| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function parse(?ResponseInterface $response): array |
||
| 19 | { |
||
| 20 | if (is_null($response)) { |
||
| 21 | throw new InvalidResponseException(Exception::RESPONSE_NONE); |
||
| 22 | } |
||
| 23 | |||
| 24 | $body = (string) $response->getBody(); |
||
| 25 | |||
| 26 | if (Str::contains($body, '&')) { |
||
| 27 | return $this->query($body); |
||
| 28 | } |
||
| 29 | |||
| 30 | $result = json_decode($body, true); |
||
| 31 | |||
| 32 | if (JSON_ERROR_NONE !== json_last_error()) { |
||
| 33 | throw new InvalidResponseException(Exception::UNPACK_RESPONSE_ERROR, 'Unpack Response Error', ['body' => $body, 'response' => $response]); |
||
| 34 | } |
||
| 35 | |||
| 36 | return $result; |
||
| 37 | } |
||
| 52 |