| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3.009 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 38 | 117 | protected function decodeJsonResponse(ResponseInterface $response): stdClass |
|
| 39 | { |
||
| 40 | 117 | $contentLength = $response->getHeaderLine('Content-Length'); |
|
| 41 | 117 | $sizeSwitch = $this->getConfig('responseSizeDecoderSwitch'); |
|
|
|
|||
| 42 | 117 | if ($contentLength < $sizeSwitch) { |
|
| 43 | 117 | return json_decode($response->getBody()->getContents(), false, 512, JSON_THROW_ON_ERROR); |
|
| 44 | } |
||
| 45 | |||
| 46 | $decodedResponse = new stdClass(); |
||
| 47 | |||
| 48 | $phpStream = StreamWrapper::getResource($response->getBody()); |
||
| 49 | $decoder = new ExtJsonDecoder(true); |
||
| 50 | $decodedStream = Items::fromStream($phpStream, ['decoder' => $decoder]); |
||
| 51 | |||
| 52 | foreach ($decodedStream as $key => $value) { |
||
| 53 | $decodedResponse->$key = $value; |
||
| 54 | } |
||
| 59 |