Conditions | 4 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 4.25 |
Changes | 0 |
1 | <?php |
||
38 | 3 | protected function jsonToArray(string $content = null): ?array |
|
39 | { |
||
40 | 3 | if (empty($content)) { |
|
41 | return null; |
||
42 | } |
||
43 | |||
44 | 3 | $this->checkContentType(); |
|
45 | |||
46 | 3 | $data = @json_decode($content, true); |
|
47 | 3 | 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 | 3 | return $data; |
|
52 | } |
||
64 |