| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 38 | 3 | protected function parse(StreamInterface $body)//: array |
|
| 39 | {
|
||
| 40 | 3 | $json = $body->__toString(); |
|
| 41 | |||
| 42 | 3 | if (! $json) |
|
| 43 | {
|
||
| 44 | 1 | return []; |
|
| 45 | } |
||
| 46 | |||
| 47 | 2 | $data = json_decode($json, $this->assoc, $this->depth, $this->opts); |
|
| 48 | |||
| 49 | 2 | if (JSON_ERROR_NONE !== json_last_error()) |
|
| 50 | {
|
||
| 51 | 1 | throw new RuntimeException('Error parsing JSON: ' . json_last_error_msg());
|
|
| 52 | } |
||
| 53 | |||
| 54 | 1 | return $data; |
|
| 55 | } |
||
| 56 | } |