1 | <?php |
||
9 | class JsonFile |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $path; |
||
15 | |||
16 | /** |
||
17 | * @param string $path |
||
18 | */ |
||
19 | public function __construct($path) |
||
23 | |||
24 | /** |
||
25 | * Reads json file. |
||
26 | * |
||
27 | * @throws \RuntimeException |
||
28 | * |
||
29 | * @return mixed |
||
30 | */ |
||
31 | public function read() |
||
75 | |||
76 | /** |
||
77 | * Writes json file. |
||
78 | * |
||
79 | * @param array $hash writes hash into json file |
||
80 | * @param int $options json_encode options (defaults to JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) |
||
81 | * |
||
82 | * @throws \RuntimeException |
||
83 | */ |
||
84 | public function write(array $hash, $options = 448) |
||
95 | } |
||
96 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: