| Total Complexity | 2 |
| Total Lines | 16 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class ArrayParser implements ParserInterface |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @throws \Yansongda\Pay\Exception\InvalidResponseException |
||
| 15 | */ |
||
| 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]); |
||
| 33 |