@@ -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): bool |
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 false; |
210 | 209 | } |
@@ -213,9 +212,9 @@ discard block |
||
213 | 212 | unset($aValues[$sName]); |
214 | 213 | $sName .= '.'; |
215 | 214 | $nNameLength = strlen($sName); |
216 | - foreach(array_keys($aValues) as $sOptionName) |
|
215 | + foreach (array_keys($aValues) as $sOptionName) |
|
217 | 216 | { |
218 | - if(substr($sOptionName, 0, $nNameLength) === $sName) |
|
217 | + if (substr($sOptionName, 0, $nNameLength) === $sName) |
|
219 | 218 | { |
220 | 219 | unset($aValues[$sOptionName]); |
221 | 220 | } |
@@ -235,9 +234,9 @@ discard block |
||
235 | 234 | { |
236 | 235 | $aValues = $xConfig->getValues(); |
237 | 236 | $bChanged = false; |
238 | - foreach($aNames as $sName) |
|
237 | + foreach ($aNames as $sName) |
|
239 | 238 | { |
240 | - if($this->deleteEntries($aValues, $sName)) |
|
239 | + if ($this->deleteEntries($aValues, $sName)) |
|
241 | 240 | { |
242 | 241 | $bChanged = true; |
243 | 242 | } |