Total Complexity | 4 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | class Json extends Base |
||
27 | { |
||
28 | public function load(string $path): array |
||
29 | { |
||
30 | if ($this->doesntExists($path)) { |
||
31 | return []; |
||
32 | } |
||
33 | |||
34 | $content = Pretty::make()->loadRaw($path); |
||
35 | |||
36 | $items = json_decode($content, true); |
||
37 | |||
38 | return $this->correct($items); |
||
39 | } |
||
40 | |||
41 | public function store(string $path, $content): string |
||
42 | { |
||
43 | Arr::storeAsJson($path, $content, false, JSON_UNESCAPED_UNICODE ^ JSON_PRETTY_PRINT); |
||
|
|||
44 | } |
||
45 | |||
46 | protected function correct(array $items): array |
||
54 | } |
||
55 | } |
||
56 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: