@@ -34,13 +34,13 @@ |
||
34 | 34 | */ |
35 | 35 | public static function containsOptions($xValue): bool |
36 | 36 | { |
37 | - if(!is_array($xValue) || count($xValue) === 0) |
|
37 | + if (!is_array($xValue) || count($xValue) === 0) |
|
38 | 38 | { |
39 | 39 | return false; |
40 | 40 | } |
41 | - foreach(array_keys($xValue) as $xKey) |
|
41 | + foreach (array_keys($xValue) as $xKey) |
|
42 | 42 | { |
43 | - if(!is_string($xKey)) |
|
43 | + if (!is_string($xKey)) |
|
44 | 44 | { |
45 | 45 | return false; |
46 | 46 | } |
@@ -35,12 +35,12 @@ |
||
35 | 35 | public static function read(string $sConfigFile): array |
36 | 36 | { |
37 | 37 | $sConfigFile = realpath($sConfigFile); |
38 | - if(!is_readable($sConfigFile)) |
|
38 | + if (!is_readable($sConfigFile)) |
|
39 | 39 | { |
40 | 40 | throw new FileAccess($sConfigFile); |
41 | 41 | } |
42 | 42 | $aConfigOptions = include($sConfigFile); |
43 | - if(!is_array($aConfigOptions)) |
|
43 | + if (!is_array($aConfigOptions)) |
|
44 | 44 | { |
45 | 45 | throw new FileContent($sConfigFile); |
46 | 46 | } |
@@ -38,17 +38,17 @@ |
||
38 | 38 | */ |
39 | 39 | public static function read(string $sConfigFile): array |
40 | 40 | { |
41 | - if(!extension_loaded('yaml')) |
|
41 | + if (!extension_loaded('yaml')) |
|
42 | 42 | { |
43 | 43 | throw new YamlExtension(); |
44 | 44 | } |
45 | 45 | $sConfigFile = realpath($sConfigFile); |
46 | - if(!is_readable($sConfigFile)) |
|
46 | + if (!is_readable($sConfigFile)) |
|
47 | 47 | { |
48 | 48 | throw new FileAccess($sConfigFile); |
49 | 49 | } |
50 | 50 | $aConfigOptions = yaml_parse_file($sConfigFile); |
51 | - if(!is_array($aConfigOptions)) |
|
51 | + if (!is_array($aConfigOptions)) |
|
52 | 52 | { |
53 | 53 | throw new FileContent($sConfigFile); |
54 | 54 | } |
@@ -37,13 +37,13 @@ |
||
37 | 37 | public static function read(string $sConfigFile): array |
38 | 38 | { |
39 | 39 | $sConfigFile = realpath($sConfigFile); |
40 | - if(!is_readable($sConfigFile)) |
|
40 | + if (!is_readable($sConfigFile)) |
|
41 | 41 | { |
42 | 42 | throw new FileAccess($sConfigFile); |
43 | 43 | } |
44 | 44 | $sFileContent = file_get_contents($sConfigFile); |
45 | 45 | $aConfigOptions = json_decode($sFileContent, true); |
46 | - if(!is_array($aConfigOptions)) |
|
46 | + if (!is_array($aConfigOptions)) |
|
47 | 47 | { |
48 | 48 | throw new FileContent($sConfigFile); |
49 | 49 | } |
@@ -38,13 +38,13 @@ |
||
38 | 38 | */ |
39 | 39 | public function read(string $sConfigFile): array |
40 | 40 | { |
41 | - if(!($sConfigFile = trim($sConfigFile))) |
|
41 | + if (!($sConfigFile = trim($sConfigFile))) |
|
42 | 42 | { |
43 | 43 | return []; |
44 | 44 | } |
45 | 45 | |
46 | 46 | $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
47 | - switch($sExt) |
|
47 | + switch ($sExt) |
|
48 | 48 | { |
49 | 49 | case 'php': |
50 | 50 | $aConfigOptions = Reader\PhpReader::read($sConfigFile); |
@@ -89,11 +89,11 @@ |
||
89 | 89 | $sKey = trim($sKey, ' .'); |
90 | 90 | $aKeys = Value::explodeName($sKey); |
91 | 91 | $aValues = $this->aValues; |
92 | - foreach($aKeys as $_sKey) |
|
92 | + foreach ($aKeys as $_sKey) |
|
93 | 93 | { |
94 | 94 | $aValues = $aValues[$_sKey] ?? []; |
95 | 95 | } |
96 | - if(!Value::containsOptions($aValues)) |
|
96 | + if (!Value::containsOptions($aValues)) |
|
97 | 97 | { |
98 | 98 | return []; |
99 | 99 | } |
@@ -44,8 +44,7 @@ discard block |
||
44 | 44 | public function newConfig(array $aOptions = [], |
45 | 45 | string $sNamePrefix = '', string $sValuePrefix = ''): Config |
46 | 46 | { |
47 | - return count($aOptions) === 0 ? new Config() : |
|
48 | - $this->setOptions(new Config(), $aOptions, $sNamePrefix, $sValuePrefix); |
|
47 | + return count($aOptions) === 0 ? new Config() : $this->setOptions(new Config(), $aOptions, $sNamePrefix, $sValuePrefix); |
|
49 | 48 | } |
50 | 49 | |
51 | 50 | /** |
@@ -77,7 +76,7 @@ discard block |
||
77 | 76 | $xValue = $xOptionValue; |
78 | 77 | $sLastName = ''; |
79 | 78 | $aNames = Value::explodeName($sOptionName); |
80 | - while($this->pop($sLastName, $aNames) > 0) |
|
79 | + while ($this->pop($sLastName, $aNames) > 0) |
|
81 | 80 | { |
82 | 81 | $sName = implode('.', $aNames); |
83 | 82 | // The current value is overwritten if it is not an array of options. |
@@ -121,15 +120,15 @@ discard block |
||
121 | 120 | string $sNamePrefix = '', int $nDepth = 0): array |
122 | 121 | { |
123 | 122 | // Check the max depth |
124 | - if($nDepth < 0 || $nDepth > 9) |
|
123 | + if ($nDepth < 0 || $nDepth > 9) |
|
125 | 124 | { |
126 | 125 | throw new DataDepth($sNamePrefix, $nDepth); |
127 | 126 | } |
128 | 127 | |
129 | - foreach($aOptions as $sName => $xValue) |
|
128 | + foreach ($aOptions as $sName => $xValue) |
|
130 | 129 | { |
131 | 130 | $sName = trim($sName); |
132 | - if(!Value::containsOptions($xValue)) |
|
131 | + if (!Value::containsOptions($xValue)) |
|
133 | 132 | { |
134 | 133 | // Save the value of this option |
135 | 134 | $aValues = $this->setValue($aValues, $sNamePrefix . $sName, $xValue); |
@@ -160,11 +159,11 @@ discard block |
||
160 | 159 | // Find the config array in the input data |
161 | 160 | $sValuePrefix = trim($sValuePrefix, ' .'); |
162 | 161 | $aKeys = Value::explodeName($sValuePrefix); |
163 | - foreach($aKeys as $sKey) |
|
162 | + foreach ($aKeys as $sKey) |
|
164 | 163 | { |
165 | - if(($sKey)) |
|
164 | + if (($sKey)) |
|
166 | 165 | { |
167 | - if(!isset($aOptions[$sKey]) || !is_array($aOptions[$sKey])) |
|
166 | + if (!isset($aOptions[$sKey]) || !is_array($aOptions[$sKey])) |
|
168 | 167 | { |
169 | 168 | // No change if the required key is not found. |
170 | 169 | return new Config($xConfig->getValues(), false); |
@@ -175,7 +174,7 @@ discard block |
||
175 | 174 | } |
176 | 175 | |
177 | 176 | $sNamePrefix = trim($sNamePrefix, ' .'); |
178 | - if(($sNamePrefix)) |
|
177 | + if (($sNamePrefix)) |
|
179 | 178 | { |
180 | 179 | $sNamePrefix .= '.'; |
181 | 180 | } |
@@ -204,7 +203,7 @@ discard block |
||
204 | 203 | private function deleteEntries(array $aValues, string $sName): array |
205 | 204 | { |
206 | 205 | $sName = rtrim($sName, '.'); |
207 | - if(!array_key_exists($sName, $aValues)) |
|
206 | + if (!array_key_exists($sName, $aValues)) |
|
208 | 207 | { |
209 | 208 | return $aValues; |
210 | 209 | } |
@@ -229,7 +228,7 @@ discard block |
||
229 | 228 | { |
230 | 229 | $aValues = $xConfig->getValues(); |
231 | 230 | $nEntryCount = count($aValues); |
232 | - foreach($aNames as $sName) |
|
231 | + foreach ($aNames as $sName) |
|
233 | 232 | { |
234 | 233 | $aValues = $this->deleteEntries($aValues, $sName); |
235 | 234 | } |