1 | <?php |
||
10 | class IniObject |
||
11 | { |
||
12 | private $filename; |
||
13 | |||
14 | protected $config; |
||
15 | |||
16 | private $sections; |
||
17 | |||
18 | /** |
||
19 | * IniObject constructor. |
||
20 | * |
||
21 | * @param string|null $filename |
||
22 | * @param array $config |
||
23 | */ |
||
24 | 10 | public function __construct(?string $filename = null, array $config = []) |
|
43 | |||
44 | /** |
||
45 | * @param array $data |
||
46 | * @throws InvalidArgumentException |
||
47 | */ |
||
48 | 10 | private function sectionLoad(array $data): void |
|
56 | |||
57 | /** |
||
58 | * @param string $name |
||
59 | * @return Section |
||
60 | */ |
||
61 | 6 | public function getSection(string $name): Section |
|
69 | |||
70 | /** |
||
71 | * @param string $name |
||
72 | */ |
||
73 | 1 | public function removeSection(string $name): void |
|
80 | |||
81 | 3 | public function addSection(string $name, array $section): void |
|
88 | |||
89 | 1 | public function updateSection(string $name, array $section): void |
|
96 | |||
97 | /** |
||
98 | * default config |
||
99 | */ |
||
100 | 10 | private function initDefaultConfig(): void |
|
107 | |||
108 | /** |
||
109 | * @param string $filename |
||
110 | */ |
||
111 | 10 | private function setFilename(?string $filename): void |
|
115 | |||
116 | 1 | public function __toString() |
|
126 | |||
127 | /** |
||
128 | * @param string|null $filename |
||
129 | * @return bool |
||
130 | */ |
||
131 | 1 | public function save(string $filename = null): bool |
|
142 | } |
||
143 |
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: