Passed
Push — main ( 273db0...683317 )
by Thierry
03:54
created
jaxon-utils/src/Translation/Translator.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function setLocale(string $sLocale): void
58 58
     {
59
-        if(($sLocale = trim($sLocale)))
59
+        if (($sLocale = trim($sLocale)))
60 60
         {
61 61
             $this->sDefaultLocale = $sLocale;
62 62
         }
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
      */
74 74
     private function _loadTranslations(string $sLanguage, string $sPrefix, array $aTranslations): void
75 75
     {
76
-        foreach($aTranslations as $sKey => $xTranslation)
76
+        foreach ($aTranslations as $sKey => $xTranslation)
77 77
         {
78 78
             $sKey = trim($sKey);
79 79
             $sKey = ($sPrefix) ? $sPrefix . '.' . $sKey : $sKey;
80
-            if(is_array($xTranslation))
80
+            if (is_array($xTranslation))
81 81
             {
82 82
                 // Recursively read the translations in the array
83 83
                 $this->_loadTranslations($sLanguage, $sKey, $xTranslation);
@@ -100,18 +100,18 @@  discard block
 block discarded – undo
100 100
      */
101 101
     public function loadTranslations(string $sFilePath, string $sLanguage): bool
102 102
     {
103
-        if(!file_exists($sFilePath))
103
+        if (!file_exists($sFilePath))
104 104
         {
105 105
             return false;
106 106
         }
107 107
         $aTranslations = require($sFilePath);
108
-        if(!is_array($aTranslations))
108
+        if (!is_array($aTranslations))
109 109
         {
110 110
             return false;
111 111
         }
112 112
 
113 113
         // Load the translations
114
-        if(!isset($this->aTranslations[$sLanguage]))
114
+        if (!isset($this->aTranslations[$sLanguage]))
115 115
         {
116 116
             $this->aTranslations[$sLanguage] = [];
117 117
         }
@@ -133,16 +133,16 @@  discard block
 block discarded – undo
133 133
     public function trans(string $sText, array $aPlaceHolders = [], string $sLanguage = ''): string
134 134
     {
135 135
         $sText = trim($sText);
136
-        if(empty($sLanguage))
136
+        if (empty($sLanguage))
137 137
         {
138 138
             $sLanguage = $this->sDefaultLocale;
139 139
         }
140
-        if(!isset($this->aTranslations[$sLanguage][$sText]))
140
+        if (!isset($this->aTranslations[$sLanguage][$sText]))
141 141
         {
142 142
             return $sText;
143 143
         }
144 144
         $sMessage = $this->aTranslations[$sLanguage][$sText];
145
-        if(!empty($aPlaceHolders))
145
+        if (!empty($aPlaceHolders))
146 146
         {
147 147
             $aVars = array_map(function($sVar) {
148 148
                 return ':' . $sVar;
@@ -162,16 +162,16 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function translations(string $sKey, string $sLanguage = ''): array
164 164
     {
165
-        if(empty($sLanguage))
165
+        if (empty($sLanguage))
166 166
         {
167 167
             $sLanguage = $this->sDefaultLocale;
168 168
         }
169 169
         $aKeys = explode('.', $sKey);
170 170
 
171 171
         $aTranslations = $this->aRawTranslations[$sLanguage];
172
-        foreach($aKeys as $sKey)
172
+        foreach ($aKeys as $sKey)
173 173
         {
174
-            if($sKey !== '')
174
+            if ($sKey !== '')
175 175
             {
176 176
                 $aTranslations = $aTranslations[$sKey] ?? [];
177 177
             }
Please login to merge, or discard this patch.
jaxon-utils/src/File/FileMinifier.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         {
38 38
             return file_get_contents($sPath);
39 39
         }
40
-        catch(Exception $e)
40
+        catch (Exception $e)
41 41
         {
42 42
             return false;
43 43
         }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         {
57 57
             return Minifier::minify($sCode);
58 58
         }
59
-        catch(Exception $e)
59
+        catch (Exception $e)
60 60
         {
61 61
             return false;
62 62
         }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function minify(string $sJsFile, string $sMinFile): bool
74 74
     {
75
-        if(($sJsCode = $this->readFile($sJsFile)) === false ||
75
+        if (($sJsCode = $this->readFile($sJsFile)) === false ||
76 76
             ($sMinCode = $this->minifyCode($sJsCode)) === false)
77 77
         {
78 78
             return false;
Please login to merge, or discard this patch.
jaxon-config/tests/TestConfig/ConfigTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 
36 36
     protected function setUp(): void
37 37
     {
38
-        $this->sConfigDir = __DIR__ .  '/../config';
38
+        $this->sConfigDir = __DIR__ . '/../config';
39 39
         $this->xConfigSetter = new ConfigSetter();
40 40
         $this->xConfigReader = new ConfigReader($this->xConfigSetter);
41 41
         $this->xConfig = $this->xConfigSetter->newConfig(['core' => ['language' => 'en']]);
Please login to merge, or discard this patch.
jaxon-config/src/Config.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,11 +90,11 @@
 block discarded – undo
90 90
         $sKey = trim($sKey, ' .');
91 91
         $aKeys = Value::explodeName($sKey);
92 92
         $aValues = $this->aValues;
93
-        foreach($aKeys as $_sKey)
93
+        foreach ($aKeys as $_sKey)
94 94
         {
95 95
             $aValues = $aValues[$_sKey] ?? [];
96 96
         }
97
-        if(!Value::containsOptions($aValues))
97
+        if (!Value::containsOptions($aValues))
98 98
         {
99 99
             return [];
100 100
         }
Please login to merge, or discard this patch.
jaxon-config/src/Reader/Value.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
jaxon-config/src/Reader/PhpReader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@
 block discarded – undo
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
 
43 43
         $aConfigOptions = include($sConfigFile);
44
-        if(!is_array($aConfigOptions))
44
+        if (!is_array($aConfigOptions))
45 45
         {
46 46
             throw new FileContent($sConfigFile);
47 47
         }
Please login to merge, or discard this patch.
jaxon-config/src/Reader/YamlReader.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,19 +38,19 @@
 block discarded – undo
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
 
46 46
         $sConfigFile = realpath($sConfigFile);
47
-        if(!is_readable($sConfigFile))
47
+        if (!is_readable($sConfigFile))
48 48
         {
49 49
             throw new FileAccess($sConfigFile);
50 50
         }
51 51
 
52 52
         $aConfigOptions = yaml_parse_file($sConfigFile);
53
-        if(!is_array($aConfigOptions))
53
+        if (!is_array($aConfigOptions))
54 54
         {
55 55
             throw new FileContent($sConfigFile);
56 56
         }
Please login to merge, or discard this patch.
jaxon-config/src/Reader/JsonReader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@
 block discarded – undo
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
 
45 45
         $sFileContent = file_get_contents($sConfigFile);
46 46
         $aConfigOptions = json_decode($sFileContent, true);
47
-        if(!is_array($aConfigOptions))
47
+        if (!is_array($aConfigOptions))
48 48
         {
49 49
             throw new FileContent($sConfigFile);
50 50
         }
Please login to merge, or discard this patch.
jaxon-config/src/ConfigSetter.php 1 patch
Spacing   +11 added lines, -12 removed lines patch added patch discarded remove patch
@@ -44,8 +44,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.