| Conditions | 4 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 4.0312 |
| Changes | 0 | ||
| 1 | <?php |
||
| 38 | 10 | protected function jsonToArray(string $content = null): ?array |
|
| 39 | { |
||
| 40 | 10 | if (empty($content)) { |
|
| 41 | 1 | return null; |
|
| 42 | } |
||
| 43 | |||
| 44 | 9 | $this->checkContentType(); |
|
| 45 | |||
| 46 | 8 | $data = @json_decode($content, true); |
|
| 47 | 8 | if ($data === null && json_last_error() !== JSON_ERROR_NONE) { |
|
| 48 | throw new \RuntimeException('It was not possible to convert the current content to JSON.'); |
||
| 49 | } |
||
| 50 | |||
| 51 | 8 | return $data; |
|
| 52 | } |
||
| 64 |