Test Failed
Push — master ( 9d3a5c...c5f273 )
by Sebastian
08:26
created
src/Request/Param/Validator/Valueslist.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,22 +36,22 @@
 block discarded – undo
36 36
         
37 37
         // if we are validating a subvalue, it means we are 
38 38
         // validating a single value in the existing list.
39
-        if($this->isSubvalue) 
39
+        if ($this->isSubvalue) 
40 40
         {
41
-            if(in_array($this->value, $allowed, true)) {
41
+            if (in_array($this->value, $allowed, true)) {
42 42
                 return $this->value;
43 43
             }
44 44
             
45 45
             return null;
46 46
         }
47 47
         
48
-        if(!is_array($this->value)) {
48
+        if (!is_array($this->value)) {
49 49
             return array();
50 50
         }
51 51
         
52 52
         $keep = array();
53
-        foreach($this->value as $item) {
54
-            if(in_array($item, $allowed, true)) {
53
+        foreach ($this->value as $item) {
54
+            if (in_array($item, $allowed, true)) {
55 55
                 $keep[] = $item;
56 56
             }
57 57
         }
Please login to merge, or discard this patch.
src/Request/Param/Validator/Regex.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     
28 28
     protected function _validate() : ?string
29 29
     {
30
-        if(!is_scalar($this->value)) {
30
+        if (!is_scalar($this->value)) {
31 31
             return null;
32 32
         }
33 33
         
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
         // is a boolean, which is converted to an integer when
36 36
         // converted to string, which in turn can be validated
37 37
         // with a regex.
38
-        if(is_bool($this->value)) {
38
+        if (is_bool($this->value)) {
39 39
             return null;
40 40
         }
41 41
         
42 42
         $value = (string)$this->value;
43 43
         
44
-        if(preg_match($this->getStringOption('regex'), $value)) {
44
+        if (preg_match($this->getStringOption('regex'), $value)) {
45 45
             return $value;
46 46
         }
47 47
         
Please login to merge, or discard this patch.
src/Request/Param/Validator/Url.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@
 block discarded – undo
27 27
     
28 28
     protected function _validate() : string
29 29
     {
30
-        if(!is_string($this->value)) {
30
+        if (!is_string($this->value)) {
31 31
             return '';
32 32
         }
33 33
         
34 34
         $info = parseURL($this->value);
35
-        if($info->isValid()) {
35
+        if ($info->isValid()) {
36 36
             return $this->value;
37 37
         }
38 38
         
Please login to merge, or discard this patch.
src/Request/Param/Validator/Json.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,13 +31,13 @@
 block discarded – undo
31 31
     
32 32
     protected function _validate() : string
33 33
     {
34
-        if(!is_string($this->value)) {
34
+        if (!is_string($this->value)) {
35 35
             return '';
36 36
         }
37 37
         
38 38
         $value = trim($this->value);
39 39
         
40
-        if(empty($value)) {
40
+        if (empty($value)) {
41 41
             return '';
42 42
         }
43 43
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -50,13 +50,11 @@
 block discarded – undo
50 50
                 {
51 51
                     return $value;
52 52
                 }
53
-            }
54
-            else if (is_array(json_decode($value, true, 512, JSON_THROW_ON_ERROR)))
53
+            } else if (is_array(json_decode($value, true, 512, JSON_THROW_ON_ERROR)))
55 54
             {
56 55
                 return $value;
57 56
             }
58
-        }
59
-        catch (Throwable $e)
57
+        } catch (Throwable $e)
60 58
         {
61 59
             // Invalid JSON must return an empty string.
62 60
             // The application is responsible for asserting
Please login to merge, or discard this patch.
src/Request/Param/Validator/Numeric.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
      */
31 31
     protected function _validate()
32 32
     {
33
-        if(is_numeric($this->value)) {
33
+        if (is_numeric($this->value)) {
34 34
             return $this->value * 1;
35 35
         }
36 36
         
Please login to merge, or discard this patch.
src/URLInfo/Parser/ParsedInfoFilter.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,8 +41,7 @@
 block discarded – undo
41 41
         if($this->hasScheme())
42 42
         {
43 43
             $this->setScheme(strtolower($this->getScheme()));
44
-        }
45
-        else
44
+        } else
46 45
         {
47 46
             $scheme = URISchemes::detectScheme($this->url);
48 47
             if(!empty($scheme)) {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     {
57 57
         $path = $this->info['path'] ?? '';
58 58
 
59
-        if(strpos($path, '@') !== false)
59
+        if (strpos($path, '@') !== false)
60 60
         {
61 61
             $this->info['path'] = str_replace(' ', '', $path);
62 62
         }
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
 
65 65
     private function filterScheme() : void
66 66
     {
67
-        if($this->hasScheme())
67
+        if ($this->hasScheme())
68 68
         {
69 69
             $this->setScheme(strtolower($this->getScheme()));
70 70
         }
71 71
         else
72 72
         {
73 73
             $scheme = URISchemes::detectScheme($this->url);
74
-            if(!empty($scheme)) {
74
+            if (!empty($scheme)) {
75 75
                 $this->setScheme(URISchemes::resolveSchemeName($scheme));
76 76
             }
77 77
         }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
     private function filterAuth() : void
81 81
     {
82
-        if(!$this->hasAuth()) {
82
+        if (!$this->hasAuth()) {
83 83
             return;
84 84
         }
85 85
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
     private function filterHost() : void
93 93
     {
94
-        if(!$this->hasHost())
94
+        if (!$this->hasHost())
95 95
         {
96 96
             return;
97 97
         }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
     private function filterPath() : void
106 106
     {
107
-        if($this->hasPath()) {
107
+        if ($this->hasPath()) {
108 108
             $this->setPath($this->getPath());
109 109
         }
110 110
     }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     {
114 114
         $host = $this->getPath();
115 115
 
116
-        if(empty($host) || !URLHosts::isHostKnown($host))
116
+        if (empty($host) || !URLHosts::isHostKnown($host))
117 117
         {
118 118
             return;
119 119
         }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         $this->setHost($host);
122 122
         $this->removePath();
123 123
 
124
-        if(!$this->hasScheme()) {
124
+        if (!$this->hasScheme()) {
125 125
             $this->setSchemeHTTPS();
126 126
         }
127 127
     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         $this->info['params'] = array();
132 132
 
133 133
         $query = $this->getQuery();
134
-        if(empty($query)) {
134
+        if (empty($query)) {
135 135
             return;
136 136
         }
137 137
 
Please login to merge, or discard this patch.
src/URLInfo/URIParser.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -285,8 +285,7 @@
 block discarded – undo
285 285
             if(is_array($val))
286 286
             {
287 287
                 $val = $this->restoreUnicodeChars($val);
288
-            }
289
-            else
288
+            } else
290 289
             {
291 290
                 $val = $this->restoreUnicodeChar($val);
292 291
             }
Please login to merge, or discard this patch.
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
     protected bool $isValid = false;
43 43
     protected bool $encodeUTF = false;
44 44
 
45
-   /**
46
-    * @var array{code:int,message:string}|NULL
47
-    */
45
+    /**
46
+     * @var array{code:int,message:string}|NULL
47
+     */
48 48
     protected ?array $error = null;
49 49
     
50
-   /**
51
-    * Stores a list of all unicode characters in the URL
52
-    * that have been filtered out before parsing it with
53
-    * parse_url.
54
-    * 
55
-    * @var array<string,string>
56
-    */
50
+    /**
51
+     * Stores a list of all unicode characters in the URL
52
+     * that have been filtered out before parsing it with
53
+     * parse_url.
54
+     * 
55
+     * @var array<string,string>
56
+     */
57 57
     protected array $unicodeChars = array();
58 58
 
59 59
     /**
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
     );
79 79
 
80 80
     /**
81
-    * 
82
-    * @param string $url The target URL.
83
-    * @param bool $encodeUTF Whether to URL encode any plain text unicode characters.
84
-    */
81
+     * 
82
+     * @param string $url The target URL.
83
+     * @param bool $encodeUTF Whether to URL encode any plain text unicode characters.
84
+     */
85 85
     public function __construct(string $url, bool $encodeUTF)
86 86
     {
87 87
         $this->url = $url;
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
         $this->validate();
93 93
     }
94 94
 
95
-   /**
96
-    * Retrieves the array as parsed by PHP's parse_url,
97
-    * filtered and adjusted as necessary.
98
-    * 
99
-    * @return array<string,mixed>
100
-    */
95
+    /**
96
+     * Retrieves the array as parsed by PHP's parse_url,
97
+     * filtered and adjusted as necessary.
98
+     * 
99
+     * @return array<string,mixed>
100
+     */
101 101
     public function getInfo() : array
102 102
     {
103 103
         return $this->info;
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
         $this->url = implode(':', $parts);
154 154
     }
155 155
 
156
-   /**
157
-    * Finds any non-url encoded unicode characters in 
158
-    * the URL, and encodes them before the URL is 
159
-    * passed to parse_url.
160
-    */
156
+    /**
157
+     * Finds any non-url encoded unicode characters in 
158
+     * the URL, and encodes them before the URL is 
159
+     * passed to parse_url.
160
+     */
161 161
     protected function filterUnicodeChars() : void
162 162
     {
163 163
         $chars = ConvertHelper::string2array($this->url);
@@ -228,23 +228,23 @@  discard block
 block discarded – undo
228 228
         $this->isValid = true;
229 229
     }
230 230
 
231
-   /**
232
-    * Goes through all information in the parse_url result
233
-    * array, and attempts to fix any user errors in formatting
234
-    * that can be recovered from, mostly regarding stray spaces.
235
-    */
231
+    /**
232
+     * Goes through all information in the parse_url result
233
+     * array, and attempts to fix any user errors in formatting
234
+     * that can be recovered from, mostly regarding stray spaces.
235
+     */
236 236
     protected function filterParsed() : void
237 237
     {
238 238
         $this->info = (new ParsedInfoFilter($this->url, $this->info))->filter();
239 239
     }
240 240
     
241
-   /**
242
-    * Recursively goes through the array, and converts all previously
243
-    * URL encoded characters with their unicode character counterparts.
244
-    * 
245
-    * @param array<string,mixed> $subject
246
-    * @return array<string,mixed>
247
-    */
241
+    /**
242
+     * Recursively goes through the array, and converts all previously
243
+     * URL encoded characters with their unicode character counterparts.
244
+     * 
245
+     * @param array<string,mixed> $subject
246
+     * @return array<string,mixed>
247
+     */
248 248
     protected function restoreUnicodeChars(array $subject) : array
249 249
     {
250 250
         $result = array();
@@ -268,13 +268,13 @@  discard block
 block discarded – undo
268 268
         return $result;
269 269
     }
270 270
     
271
-   /**
272
-    * Replaces all URL encoded unicode characters
273
-    * in the string with the unicode character.
274
-    * 
275
-    * @param string $string
276
-    * @return string
277
-    */
271
+    /**
272
+     * Replaces all URL encoded unicode characters
273
+     * in the string with the unicode character.
274
+     * 
275
+     * @param string $string
276
+     * @return string
277
+     */
278 278
     protected function restoreUnicodeChar(string $string) : string
279 279
     {
280 280
         if(strpos($string, '%') !== false)
@@ -295,32 +295,32 @@  discard block
 block discarded – undo
295 295
         );
296 296
     }
297 297
    
298
-   /**
299
-    * Checks whether the URL that was parsed is valid.
300
-    * @return bool
301
-    */
298
+    /**
299
+     * Checks whether the URL that was parsed is valid.
300
+     * @return bool
301
+     */
302 302
     public function isValid() : bool
303 303
     {
304 304
         return $this->isValid;
305 305
     }
306 306
 
307
-   /**
308
-    * If the validation failed, retrieves the validation
309
-    * error message.
310
-    * 
311
-    * @return string
312
-    */
307
+    /**
308
+     * If the validation failed, retrieves the validation
309
+     * error message.
310
+     * 
311
+     * @return string
312
+     */
313 313
     public function getErrorMessage() : string
314 314
     {
315 315
         return $this->error['message'] ?? '';
316 316
     }
317 317
     
318
-   /**
319
-    * If the validation failed, retrieves the validation
320
-    * error code.
321
-    * 
322
-    * @return int
323
-    */
318
+    /**
319
+     * If the validation failed, retrieves the validation
320
+     * error code.
321
+     * 
322
+     * @return int
323
+     */
324 324
     public function getErrorCode() : int
325 325
     {
326 326
         return $this->error['code'] ?? -1;
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
         $result = parse_url($this->url);
111 111
         $this->info = array();
112 112
 
113
-        if(!is_array($result))
113
+        if (!is_array($result))
114 114
         {
115 115
             $this->fixBrokenURL();
116 116
             $result = parse_url($this->url);
117 117
         }
118 118
 
119
-        if(is_array($result))
119
+        if (is_array($result))
120 120
         {
121 121
             $this->info = $result;
122 122
         }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
         // if the URL contains any URL characters, and we
127 127
         // do not want them URL encoded, restore them.
128
-        if(!$this->encodeUTF && !empty($this->unicodeChars))
128
+        if (!$this->encodeUTF && !empty($this->unicodeChars))
129 129
         {
130 130
             $this->info = $this->restoreUnicodeChars($this->info);
131 131
         }
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      */
138 138
     private function fixBrokenURL() : void
139 139
     {
140
-        if(strpos($this->url, ':') === false) {
140
+        if (strpos($this->url, ':') === false) {
141 141
             return;
142 142
         }
143 143
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         // else, as unlikely as it may be.
146 146
         $parts = explode(':', $this->url);
147 147
 
148
-        while(strpos($parts[1], '///') === 0)
148
+        while (strpos($parts[1], '///') === 0)
149 149
         {
150 150
             $parts[1] = str_replace('///', '//', $parts[1]);
151 151
         }
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
         
165 165
         $keep = array();
166 166
         
167
-        foreach($chars as $char)
167
+        foreach ($chars as $char)
168 168
         {
169
-            if(preg_match('/\p{L}/uix', $char))
169
+            if (preg_match('/\p{L}/uix', $char))
170 170
             {
171 171
                 $encoded = rawurlencode($char);
172 172
                 
173
-                if($encoded !== $char)
173
+                if ($encoded !== $char)
174 174
                 {
175 175
                     $this->unicodeChars[$encoded] = $char;
176 176
                     $char = $encoded;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
     protected function detectType() : bool
187 187
     {
188
-        foreach(self::$detectorClasses as $className)
188
+        foreach (self::$detectorClasses as $className)
189 189
         {
190 190
             $detector = ClassHelper::requireObjectInstanceOf(
191 191
                 BaseURLTypeDetector::class,
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             // Use the adjusted data
198 198
             $this->info = $detector->getInfo();
199 199
 
200
-            if($detected) {
200
+            if ($detected) {
201 201
                 $this->isValid = true;
202 202
                 return true;
203 203
             }
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 
209 209
     protected function validate() : void
210 210
     {
211
-        foreach(self::$validatorClasses as $validatorClass)
211
+        foreach (self::$validatorClasses as $validatorClass)
212 212
         {
213 213
             $validator = ClassHelper::requireObjectInstanceOf(
214 214
                 BaseURLValidator::class,
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
             $this->info = $validator->getInfo();
221 221
 
222
-            if($result !== true) {
222
+            if ($result !== true) {
223 223
                 $this->isValid = false;
224 224
                 return;
225 225
             }
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
     {
250 250
         $result = array();
251 251
         
252
-        foreach($subject as $key => $val)
252
+        foreach ($subject as $key => $val)
253 253
         {
254
-            if(is_array($val))
254
+            if (is_array($val))
255 255
             {
256 256
                 $val = $this->restoreUnicodeChars($val);
257 257
             }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     */
278 278
     protected function restoreUnicodeChar(string $string) : string
279 279
     {
280
-        if(strpos($string, '%') !== false)
280
+        if (strpos($string, '%') !== false)
281 281
         {
282 282
             return str_replace(array_keys($this->unicodeChars), array_values($this->unicodeChars), $string);
283 283
         }
Please login to merge, or discard this patch.
src/URLInfo/URLHosts.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 
18 18
     public static function addHost(string $host) : void
19 19
     {
20
-        if(!self::isHostKnown($host)) {
20
+        if (!self::isHostKnown($host)) {
21 21
             self::$knownHosts[] = strtolower($host);
22 22
         }
23 23
     }
Please login to merge, or discard this patch.
src/URLInfo/Parser/URLTypeDetector/DetectEmail.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@
 block discarded – undo
22 22
 {
23 23
     public function detect() : bool
24 24
     {
25
-        if($this->getScheme() === 'mailto') {
25
+        if ($this->getScheme() === 'mailto') {
26 26
             $this->setHostFromEmail((string)$this->getPath());
27 27
             $this->setTypeEmail();
28 28
             return true;
29 29
         }
30 30
 
31
-        if($this->hasPath() && preg_match(RegexHelper::REGEX_EMAIL, $this->getPath()))
31
+        if ($this->hasPath() && preg_match(RegexHelper::REGEX_EMAIL, $this->getPath()))
32 32
         {
33 33
             $this->setHostFromEmail($this->getPath());
34 34
             $this->setSchemeMailto();
Please login to merge, or discard this patch.