Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public function parse(?ResponseInterface $response): array |
||
17 | { |
||
18 | if (is_null($response)) { |
||
19 | throw new InvalidResponseException(InvalidResponseException::RESPONSE_NONE); |
||
20 | } |
||
21 | |||
22 | $contents = $response->getBody()->getContents(); |
||
23 | |||
24 | $result = json_decode($contents, true); |
||
25 | |||
26 | if (JSON_ERROR_NONE !== json_last_error()) { |
||
27 | throw new InvalidResponseException(InvalidResponseException::UNPACK_RESPONSE_ERROR, 'Unpack Response Error', [$contents]); |
||
28 | } |
||
29 | |||
30 | return $result; |
||
31 | } |
||
33 |