Passed
Push — main ( 144de1...77b9e9 )
by Thierry
02:56
created
src/Validation/Validator.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     {
134 134
         $xDefault = $this->xConfig->getOption('upload.default.' . $sProperty);
135 135
         $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.' . $sProperty, $xDefault);
136
-        if(is_array($aAllowed) && !in_array($sValue, $aAllowed))
136
+        if (is_array($aAllowed) && !in_array($sValue, $aAllowed))
137 137
         {
138 138
             $this->sErrorMessage = $this->xTranslator->trans('errors.upload.' . $sField, [$sField => $sValue]);
139 139
             return false;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
     {
155 155
         $xDefault = $this->xConfig->getOption('upload.default.' . $sProperty, 0);
156 156
         $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.' . $sProperty, $xDefault);
157
-        if($iSize > 0 && (
157
+        if ($iSize > 0 && (
158 158
             ($sProperty == 'max-size' && $iFileSize > $iSize) ||
159 159
             ($sProperty == 'min-size' && $iFileSize < $iSize)))
160 160
         {
@@ -176,25 +176,25 @@  discard block
 block discarded – undo
176 176
     {
177 177
         $this->sErrorMessage = '';
178 178
         // Verify the file extension
179
-        if(!$this->validateFileProperty($sName, $aUploadedFile['type'], 'types', 'type'))
179
+        if (!$this->validateFileProperty($sName, $aUploadedFile['type'], 'types', 'type'))
180 180
         {
181 181
             return false;
182 182
         }
183 183
 
184 184
         // Verify the file extension
185
-        if(!$this->validateFileProperty($sName, $aUploadedFile['extension'], 'extensions', 'extension'))
185
+        if (!$this->validateFileProperty($sName, $aUploadedFile['extension'], 'extensions', 'extension'))
186 186
         {
187 187
             return false;
188 188
         }
189 189
 
190 190
         // Verify the max size
191
-        if(!$this->validateFileSize($sName, $aUploadedFile['size'], 'max-size'))
191
+        if (!$this->validateFileSize($sName, $aUploadedFile['size'], 'max-size'))
192 192
         {
193 193
             return false;
194 194
         }
195 195
 
196 196
         // Verify the min size
197
-        if(!$this->validateFileSize($sName, $aUploadedFile['size'], 'min-size'))
197
+        if (!$this->validateFileSize($sName, $aUploadedFile['size'], 'min-size'))
198 198
         {
199 199
             return false;
200 200
         }
Please login to merge, or discard this patch.
src/Template/Engine.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     {
65 65
         // Make the template vars available, throught a Context object.
66 66
         $xContext = new Context($this);
67
-        foreach($aVars as $sName => $xValue)
67
+        foreach ($aVars as $sName => $xValue)
68 68
         {
69 69
             $sName = (string)$sName;
70 70
             $xContext->$sName = $xValue;
@@ -94,18 +94,18 @@  discard block
 block discarded – undo
94 94
         // Get the namespace name
95 95
         $sNamespace = '';
96 96
         $iSeparatorPosition = strrpos($sTemplate, '::');
97
-        if($iSeparatorPosition !== false)
97
+        if ($iSeparatorPosition !== false)
98 98
         {
99 99
             $sNamespace = substr($sTemplate, 0, $iSeparatorPosition);
100 100
             $sTemplate = substr($sTemplate, $iSeparatorPosition + 2);
101 101
         }
102 102
         // The default namespace is 'jaxon'
103
-        if(!($sNamespace = trim($sNamespace)))
103
+        if (!($sNamespace = trim($sNamespace)))
104 104
         {
105 105
             $sNamespace = 'jaxon';
106 106
         }
107 107
         // Check if the namespace is defined
108
-        if(!key_exists($sNamespace, $this->aNamespaces))
108
+        if (!key_exists($sNamespace, $this->aNamespaces))
109 109
         {
110 110
             return '';
111 111
         }
Please login to merge, or discard this patch.
src/Http/URI.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
             if(strpos($_SERVER[$sKey], ':') > 0)
32 32
             {
33 33
                 list($aURL['host'], $aURL['port']) = explode(':', $_SERVER[$sKey]);
34
-            }
35
-            else
34
+            } else
36 35
             {
37 36
                 $aURL['host'] = $_SERVER[$sKey];
38 37
             }
@@ -65,8 +64,7 @@  discard block
 block discarded – undo
65 64
             if(!empty($_SERVER['HTTP_SCHEME']))
66 65
             {
67 66
                 $aURL['scheme'] = $_SERVER['HTTP_SCHEME'];
68
-            }
69
-            else
67
+            } else
70 68
             {
71 69
                 $aURL['scheme'] = ((!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http');
72 70
             }
@@ -95,8 +93,7 @@  discard block
 block discarded – undo
95 93
             if(!empty($_SERVER['PATH_INFO']))
96 94
             {
97 95
                 $sPath = parse_url($_SERVER['PATH_INFO']);
98
-            }
99
-            else
96
+            } else
100 97
             {
101 98
                 $sPath = parse_url($_SERVER['PHP_SELF']);
102 99
             }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
      */
27 27
     private function getHostFromServer(array &$aURL, string $sKey)
28 28
     {
29
-        if(empty($aURL['host']) && !empty($_SERVER[$sKey]))
29
+        if (empty($aURL['host']) && !empty($_SERVER[$sKey]))
30 30
         {
31
-            if(strpos($_SERVER[$sKey], ':') > 0)
31
+            if (strpos($_SERVER[$sKey], ':') > 0)
32 32
             {
33 33
                 list($aURL['host'], $aURL['port']) = explode(':', $_SERVER[$sKey]);
34 34
             }
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $aURL = [];
51 51
         // Try to get the request URL
52
-        if(!empty($_SERVER['REQUEST_URI']))
52
+        if (!empty($_SERVER['REQUEST_URI']))
53 53
         {
54 54
             $_SERVER['REQUEST_URI'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $_SERVER['REQUEST_URI']);
55 55
             $aURL = parse_url($_SERVER['REQUEST_URI']);
56 56
         }
57 57
 
58 58
         // Fill in the empty values
59
-        if(empty($aURL['scheme']))
59
+        if (empty($aURL['scheme']))
60 60
         {
61
-            if(!empty($_SERVER['HTTP_SCHEME']))
61
+            if (!empty($_SERVER['HTTP_SCHEME']))
62 62
             {
63 63
                 $aURL['scheme'] = $_SERVER['HTTP_SCHEME'];
64 64
             }
@@ -71,24 +71,24 @@  discard block
 block discarded – undo
71 71
         $this->getHostFromServer($aURL, 'HTTP_X_FORWARDED_HOST');
72 72
         $this->getHostFromServer($aURL, 'HTTP_HOST');
73 73
         $this->getHostFromServer($aURL, 'SERVER_NAME');
74
-        if(empty($aURL['host']))
74
+        if (empty($aURL['host']))
75 75
         {
76 76
             throw new Error();
77 77
         }
78 78
 
79
-        if(empty($aURL['port']) && !empty($_SERVER['SERVER_PORT']))
79
+        if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT']))
80 80
         {
81 81
             $aURL['port'] = $_SERVER['SERVER_PORT'];
82 82
         }
83 83
 
84
-        if(!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0)
84
+        if (!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0)
85 85
         {
86 86
             unset($aURL['path']);
87 87
         }
88 88
 
89
-        if(empty($aURL['path']))
89
+        if (empty($aURL['path']))
90 90
         {
91
-            if(!empty($_SERVER['PATH_INFO']))
91
+            if (!empty($_SERVER['PATH_INFO']))
92 92
             {
93 93
                 $sPath = parse_url($_SERVER['PATH_INFO']);
94 94
             }
@@ -96,29 +96,29 @@  discard block
 block discarded – undo
96 96
             {
97 97
                 $sPath = parse_url($_SERVER['PHP_SELF']);
98 98
             }
99
-            if(isset($sPath['path']))
99
+            if (isset($sPath['path']))
100 100
             {
101 101
                 $aURL['path'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $sPath['path']);
102 102
             }
103 103
             unset($sPath);
104 104
         }
105 105
 
106
-        if(empty($aURL['query']))
106
+        if (empty($aURL['query']))
107 107
         {
108 108
             $aURL['query'] = empty($_SERVER['QUERY_STRING']) ? '' : $_SERVER['QUERY_STRING'];
109 109
         }
110 110
 
111
-        if(!empty($aURL['query']))
111
+        if (!empty($aURL['query']))
112 112
         {
113 113
             $aURL['query'] = '?' . $aURL['query'];
114 114
         }
115 115
 
116 116
         // Build the URL: Start with scheme, user and pass
117 117
         $sURL = $aURL['scheme'] . '://';
118
-        if(!empty($aURL['user']))
118
+        if (!empty($aURL['user']))
119 119
         {
120 120
             $sURL .= $aURL['user'];
121
-            if(!empty($aURL['pass']))
121
+            if (!empty($aURL['pass']))
122 122
             {
123 123
                 $sURL .= ':' . $aURL['pass'];
124 124
             }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         $sURL .= $aURL['host'];
130 130
 
131 131
         // Add the port if needed
132
-        if(!empty($aURL['port']) &&
132
+        if (!empty($aURL['port']) &&
133 133
             (($aURL['scheme'] == 'http' && $aURL['port'] != 80) ||
134 134
             ($aURL['scheme'] == 'https' && $aURL['port'] != 443)))
135 135
         {
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 
145 145
         $aURL = explode("?", $sURL);
146 146
 
147
-        if(1 < count($aURL))
147
+        if (1 < count($aURL))
148 148
         {
149 149
             $aQueries = explode("&", $aURL[1]);
150 150
 
151
-            foreach($aQueries as $sKey => $sQuery)
151
+            foreach ($aQueries as $sKey => $sQuery)
152 152
             {
153
-                if("jxnGenerate" == substr($sQuery, 0, 11))
153
+                if ("jxnGenerate" == substr($sQuery, 0, 11))
154 154
                 {
155 155
                     unset($aQueries[$sKey]);
156 156
                 }
Please login to merge, or discard this patch.
src/Translation/Translator.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,8 +76,7 @@
 block discarded – undo
76 76
             {
77 77
                 // Save this translation
78 78
                 $this->aTranslations[$sLanguage][$sName] = $xTranslation;
79
-            }
80
-            else
79
+            } else
81 80
             {
82 81
                 // Recursively read the translations in the array
83 82
                 $this->_loadTranslations($sLanguage, $sName, $xTranslation);
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
      */
62 62
     private function _loadTranslations(string $sLanguage, string $sPrefix, array $aTranslations)
63 63
     {
64
-        foreach($aTranslations as $sName => $xTranslation)
64
+        foreach ($aTranslations as $sName => $xTranslation)
65 65
         {
66 66
             $sName = trim($sName);
67 67
             $sName = ($sPrefix) ? $sPrefix . '.' . $sName : $sName;
68
-            if(!is_array($xTranslation))
68
+            if (!is_array($xTranslation))
69 69
             {
70 70
                 // Save this translation
71 71
                 $this->aTranslations[$sLanguage][$sName] = $xTranslation;
@@ -88,17 +88,17 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function loadTranslations(string $sFilePath, string $sLanguage)
90 90
     {
91
-        if(!file_exists($sFilePath))
91
+        if (!file_exists($sFilePath))
92 92
         {
93 93
             return;
94 94
         }
95 95
         $aTranslations = require($sFilePath);
96
-        if(!is_array($aTranslations))
96
+        if (!is_array($aTranslations))
97 97
         {
98 98
             return;
99 99
         }
100 100
         // Load the translations
101
-        if(!array_key_exists($sLanguage, $this->aTranslations))
101
+        if (!array_key_exists($sLanguage, $this->aTranslations))
102 102
         {
103 103
             $this->aTranslations[$sLanguage] = [];
104 104
         }
@@ -117,20 +117,20 @@  discard block
 block discarded – undo
117 117
     public function trans(string $sText, array $aPlaceHolders = [], string $sLanguage = '')
118 118
     {
119 119
         $sText = trim($sText);
120
-        if(!$sLanguage)
120
+        if (!$sLanguage)
121 121
         {
122 122
             $sLanguage = $this->xConfig->getOption('language', 'en');
123 123
         }
124
-        if(!$sLanguage)
124
+        if (!$sLanguage)
125 125
         {
126 126
             $sLanguage = $this->sDefaultLocale;
127 127
         }
128
-        if(!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage]))
128
+        if (!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage]))
129 129
         {
130 130
             return $sText;
131 131
         }
132 132
         $message = $this->aTranslations[$sLanguage][$sText];
133
-        foreach($aPlaceHolders as $name => $value)
133
+        foreach ($aPlaceHolders as $name => $value)
134 134
         {
135 135
             $message = str_replace(':' . $name, $value, $message);
136 136
         }
Please login to merge, or discard this patch.
src/Config/Reader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@
 block discarded – undo
40 40
      */
41 41
     public function read(string $sConfigFile)
42 42
     {
43
-        if(!($sConfigFile = trim($sConfigFile)))
43
+        if (!($sConfigFile = trim($sConfigFile)))
44 44
         {
45 45
             return [];
46 46
         }
47 47
 
48 48
         $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION);
49
-        switch($sExt)
49
+        switch ($sExt)
50 50
         {
51 51
         case 'php':
52 52
             $aConfigOptions = Php::read($sConfigFile);
Please login to merge, or discard this patch.
src/Config/Json.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@
 block discarded – undo
34 34
     public static function read(string $sConfigFile)
35 35
     {
36 36
         $sConfigFile = realpath($sConfigFile);
37
-        if(!is_readable($sConfigFile))
37
+        if (!is_readable($sConfigFile))
38 38
         {
39 39
             throw new Exception\FileAccess($sConfigFile);
40 40
         }
41 41
         $sFileContent = file_get_contents($sConfigFile);
42 42
         $aConfigOptions = json_decode($sFileContent, true);
43
-        if(!is_array($aConfigOptions))
43
+        if (!is_array($aConfigOptions))
44 44
         {
45 45
             throw new Exception\FileContent($sConfigFile);
46 46
         }
Please login to merge, or discard this patch.
src/Config/Php.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@
 block discarded – undo
32 32
     public static function read(string $sConfigFile)
33 33
     {
34 34
         $sConfigFile = realpath($sConfigFile);
35
-        if(!is_readable($sConfigFile))
35
+        if (!is_readable($sConfigFile))
36 36
         {
37 37
             throw new Exception\FileAccess($sConfigFile);
38 38
         }
39 39
         $aConfigOptions = include($sConfigFile);
40
-        if(!is_array($aConfigOptions))
40
+        if (!is_array($aConfigOptions))
41 41
         {
42 42
             throw new Exception\FileContent($sConfigFile);
43 43
         }
Please login to merge, or discard this patch.
src/Config/Config.php 1 patch
Spacing   +11 added lines, -12 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function __construct(array $aOptions = [], string $sKeys = '')
48 48
     {
49
-        if(count($aOptions) > 0)
49
+        if (count($aOptions) > 0)
50 50
         {
51 51
             $this->setOptions($aOptions, $sKeys);
52 52
         }
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
         $sPrefix = trim((string)$sPrefix);
81 81
         $nDepth = intval($nDepth);
82 82
         // Check the max depth
83
-        if($nDepth < 0 || $nDepth > 9)
83
+        if ($nDepth < 0 || $nDepth > 9)
84 84
         {
85 85
             throw new Exception\DataDepth($sPrefix, $nDepth);
86 86
         }
87
-        foreach($aOptions as $sName => $xOption)
87
+        foreach ($aOptions as $sName => $xOption)
88 88
         {
89
-            if(is_int($sName))
89
+            if (is_int($sName))
90 90
             {
91 91
                 continue;
92 92
             }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             // Save the value of this option
97 97
             $this->aOptions[$sFullName] = $xOption;
98 98
             // Save the values of its sub-options
99
-            if(is_array($xOption))
99
+            if (is_array($xOption))
100 100
             {
101 101
                 // Recursively read the options in the array
102 102
                 $this->_setOptions($xOption, $sFullName, $nDepth + 1);
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
     {
118 118
         // Find the config array in the input data
119 119
         $aKeys = explode('.', (string)$sKeys);
120
-        foreach($aKeys as $sKey)
120
+        foreach ($aKeys as $sKey)
121 121
         {
122
-            if(($sKey))
122
+            if (($sKey))
123 123
             {
124
-                if(!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey]))
124
+                if (!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey]))
125 125
                 {
126 126
                     return $this;
127 127
                 }
@@ -170,14 +170,13 @@  discard block
 block discarded – undo
170 170
         $sPrefix = rtrim(trim($sPrefix), '.') . '.';
171 171
         $sPrefixLen = strlen($sPrefix);
172 172
         $aOptions = [];
173
-        foreach($this->aOptions as $sName => $xValue)
173
+        foreach ($this->aOptions as $sName => $xValue)
174 174
         {
175
-            if(substr($sName, 0, $sPrefixLen) == $sPrefix)
175
+            if (substr($sName, 0, $sPrefixLen) == $sPrefix)
176 176
             {
177 177
                 $iNextDotPos = strpos($sName, '.', $sPrefixLen);
178 178
                 $sOptionName = $iNextDotPos === false ?
179
-                    substr($sName, $sPrefixLen) :
180
-                    substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen);
179
+                    substr($sName, $sPrefixLen) : substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen);
181 180
                 $aOptions[$sOptionName] = $sPrefix . $sOptionName;
182 181
             }
183 182
         }
Please login to merge, or discard this patch.
src/Config/Yaml.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,16 +35,16 @@
 block discarded – undo
35 35
     public static function read(string $sConfigFile)
36 36
     {
37 37
         $sConfigFile = realpath($sConfigFile);
38
-        if(!extension_loaded('yaml'))
38
+        if (!extension_loaded('yaml'))
39 39
         {
40 40
             throw new Exception\YamlExtension();
41 41
         }
42
-        if(!is_readable($sConfigFile))
42
+        if (!is_readable($sConfigFile))
43 43
         {
44 44
             throw new Exception\FileAccess($sConfigFile);
45 45
         }
46 46
         $aConfigOptions = yaml_parse_file($sConfigFile);
47
-        if(!is_array($aConfigOptions))
47
+        if (!is_array($aConfigOptions))
48 48
         {
49 49
             throw new Exception\FileContent($sConfigFile);
50 50
         }
Please login to merge, or discard this patch.