@@ -91,12 +91,12 @@ |
||
91 | 91 | $sKey = trim($sKey, ' .'); |
92 | 92 | $aKeys = Value::explodeName($sKey); |
93 | 93 | $aValues = $this->aValues; |
94 | - foreach($aKeys as $_sKey) |
|
94 | + foreach ($aKeys as $_sKey) |
|
95 | 95 | { |
96 | 96 | $aValues = $aValues[$_sKey] ?? []; |
97 | 97 | } |
98 | 98 | $aValues = array_filter($aValues, fn($xValue) => Value::containsOptions($xValue)); |
99 | - if(count($aValues) === 0) |
|
99 | + if (count($aValues) === 0) |
|
100 | 100 | { |
101 | 101 | return []; |
102 | 102 | } |
@@ -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 | } |
@@ -39,8 +39,7 @@ discard block |
||
39 | 39 | public function newConfig(array $aOptions = [], |
40 | 40 | string $sNamePrefix = '', string $sValuePrefix = ''): Config |
41 | 41 | { |
42 | - return count($aOptions) === 0 ? new Config() : |
|
43 | - $this->setOptions(new Config(), $aOptions, $sNamePrefix, $sValuePrefix); |
|
42 | + return count($aOptions) === 0 ? new Config() : $this->setOptions(new Config(), $aOptions, $sNamePrefix, $sValuePrefix); |
|
44 | 43 | } |
45 | 44 | |
46 | 45 | /** |
@@ -72,7 +71,7 @@ discard block |
||
72 | 71 | $xValue = $xOptionValue; |
73 | 72 | $sLastName = ''; |
74 | 73 | $aNames = Value::explodeName($sOptionName); |
75 | - while($this->pop($sLastName, $aNames) > 0) |
|
74 | + while ($this->pop($sLastName, $aNames) > 0) |
|
76 | 75 | { |
77 | 76 | $sName = implode('.', $aNames); |
78 | 77 | // The current value is overwritten if it is not an array of options. |
@@ -116,15 +115,15 @@ discard block |
||
116 | 115 | string $sNamePrefix = '', int $nDepth = 0): array |
117 | 116 | { |
118 | 117 | // Check the max depth |
119 | - if($nDepth < 0 || $nDepth > 9) |
|
118 | + if ($nDepth < 0 || $nDepth > 9) |
|
120 | 119 | { |
121 | 120 | throw new DataDepth($sNamePrefix, $nDepth); |
122 | 121 | } |
123 | 122 | |
124 | - foreach($aOptions as $sName => $xValue) |
|
123 | + foreach ($aOptions as $sName => $xValue) |
|
125 | 124 | { |
126 | 125 | $sName = trim($sName); |
127 | - if(Value::containsOptions($xValue)) |
|
126 | + if (Value::containsOptions($xValue)) |
|
128 | 127 | { |
129 | 128 | // Recursively set the options in the array. Important to set a new var. |
130 | 129 | $sNextPrefix = $sNamePrefix . $sName . '.'; |
@@ -155,11 +154,11 @@ discard block |
||
155 | 154 | // Find the config array in the input data |
156 | 155 | $sValuePrefix = trim($sValuePrefix, ' .'); |
157 | 156 | $aKeys = Value::explodeName($sValuePrefix); |
158 | - foreach($aKeys as $sKey) |
|
157 | + foreach ($aKeys as $sKey) |
|
159 | 158 | { |
160 | - if(($sKey)) |
|
159 | + if (($sKey)) |
|
161 | 160 | { |
162 | - if(!isset($aOptions[$sKey]) || !is_array($aOptions[$sKey])) |
|
161 | + if (!isset($aOptions[$sKey]) || !is_array($aOptions[$sKey])) |
|
163 | 162 | { |
164 | 163 | // No change if the required key is not found. |
165 | 164 | return new Config($xConfig->getValues(), false); |
@@ -170,7 +169,7 @@ discard block |
||
170 | 169 | } |
171 | 170 | |
172 | 171 | $sNamePrefix = trim($sNamePrefix, ' .'); |
173 | - if(($sNamePrefix)) |
|
172 | + if (($sNamePrefix)) |
|
174 | 173 | { |
175 | 174 | $sNamePrefix .= '.'; |
176 | 175 | } |
@@ -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); |