Passed
Push — master ( a3db06...6080f3 )
by Sebastian
03:13
created
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
 
62 60
         }
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
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 
39 39
     private function filterScheme() : void
40 40
     {
41
-        if($this->hasScheme())
41
+        if ($this->hasScheme())
42 42
         {
43 43
             $this->setScheme(strtolower($this->getScheme()));
44 44
         }
45 45
         else
46 46
         {
47 47
             $scheme = URISchemes::detectScheme($this->url);
48
-            if(!empty($scheme)) {
48
+            if (!empty($scheme)) {
49 49
                 $this->setScheme(URISchemes::resolveSchemeName($scheme));
50 50
             }
51 51
         }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
     private function filterAuth() : void
55 55
     {
56
-        if(!$this->hasAuth()) {
56
+        if (!$this->hasAuth()) {
57 57
             return;
58 58
         }
59 59
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
     private function filterHost() : void
67 67
     {
68
-        if(!$this->hasHost())
68
+        if (!$this->hasHost())
69 69
         {
70 70
             return;
71 71
         }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
     private function filterPath() : void
80 80
     {
81
-        if($this->hasPath()) {
81
+        if ($this->hasPath()) {
82 82
             $this->setPath(str_replace(' ', '', $this->getPath()));
83 83
         }
84 84
     }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     {
88 88
         $host = $this->getPath();
89 89
 
90
-        if(empty($host) || !URLHosts::isHostKnown($host))
90
+        if (empty($host) || !URLHosts::isHostKnown($host))
91 91
         {
92 92
             return;
93 93
         }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         $this->setHost($host);
96 96
         $this->removePath();
97 97
 
98
-        if(!$this->hasScheme()) {
98
+        if (!$this->hasScheme()) {
99 99
             $this->setSchemeHTTPS();
100 100
         }
101 101
     }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         $this->info['params'] = array();
106 106
 
107 107
         $query = $this->getQuery();
108
-        if(empty($query)) {
108
+        if (empty($query)) {
109 109
             return;
110 110
         }
111 111
 
Please login to merge, or discard this patch.
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.
src/URLInfo/URIParser.php 3 patches
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
100
-    */
95
+    /**
96
+     * Retrieves the array as parsed by PHP's parse_url,
97
+     * filtered and adjusted as necessary.
98
+     * 
99
+     * @return array
100
+     */
101 101
     public function getInfo() : array
102 102
     {
103 103
         return $this->info;
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
         }
120 120
     }
121 121
 
122
-   /**
123
-    * Finds any non-url encoded unicode characters in 
124
-    * the URL, and encodes them before the URL is 
125
-    * passed to parse_url.
126
-    */
122
+    /**
123
+     * Finds any non-url encoded unicode characters in 
124
+     * the URL, and encodes them before the URL is 
125
+     * passed to parse_url.
126
+     */
127 127
     protected function filterUnicodeChars() : void
128 128
     {
129 129
         $chars = ConvertHelper::string2array($this->url);
@@ -194,23 +194,23 @@  discard block
 block discarded – undo
194 194
         $this->isValid = true;
195 195
     }
196 196
 
197
-   /**
198
-    * Goes through all information in the parse_url result
199
-    * array, and attempts to fix any user errors in formatting
200
-    * that can be recovered from, mostly regarding stray spaces.
201
-    */
197
+    /**
198
+     * Goes through all information in the parse_url result
199
+     * array, and attempts to fix any user errors in formatting
200
+     * that can be recovered from, mostly regarding stray spaces.
201
+     */
202 202
     protected function filterParsed() : void
203 203
     {
204 204
         $this->info = (new ParsedInfoFilter($this->url, $this->info))->filter();
205 205
     }
206 206
     
207
-   /**
208
-    * Recursively goes through the array, and converts all previously
209
-    * URL encoded characters with their unicode character counterparts.
210
-    * 
211
-    * @param array $subject
212
-    * @return array
213
-    */
207
+    /**
208
+     * Recursively goes through the array, and converts all previously
209
+     * URL encoded characters with their unicode character counterparts.
210
+     * 
211
+     * @param array $subject
212
+     * @return array
213
+     */
214 214
     protected function restoreUnicodeChars(array $subject) : array
215 215
     {
216 216
         $result = array();
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
         return $result;
235 235
     }
236 236
     
237
-   /**
238
-    * Replaces all URL encoded unicode characters
239
-    * in the string with the unicode character.
240
-    * 
241
-    * @param string $string
242
-    * @return string
243
-    */
237
+    /**
238
+     * Replaces all URL encoded unicode characters
239
+     * in the string with the unicode character.
240
+     * 
241
+     * @param string $string
242
+     * @return string
243
+     */
244 244
     protected function restoreUnicodeChar(string $string) : string
245 245
     {
246 246
         if(strpos($string, '%') !== false)
@@ -261,32 +261,32 @@  discard block
 block discarded – undo
261 261
         );
262 262
     }
263 263
    
264
-   /**
265
-    * Checks whether the URL that was parsed is valid.
266
-    * @return bool
267
-    */
264
+    /**
265
+     * Checks whether the URL that was parsed is valid.
266
+     * @return bool
267
+     */
268 268
     public function isValid() : bool
269 269
     {
270 270
         return $this->isValid;
271 271
     }
272 272
 
273
-   /**
274
-    * If the validation failed, retrieves the validation
275
-    * error message.
276
-    * 
277
-    * @return string
278
-    */
273
+    /**
274
+     * If the validation failed, retrieves the validation
275
+     * error message.
276
+     * 
277
+     * @return string
278
+     */
279 279
     public function getErrorMessage() : string
280 280
     {
281 281
         return $this->error['message'] ?? '';
282 282
     }
283 283
     
284
-   /**
285
-    * If the validation failed, retrieves the validation
286
-    * error code.
287
-    * 
288
-    * @return int
289
-    */
284
+    /**
285
+     * If the validation failed, retrieves the validation
286
+     * error code.
287
+     * 
288
+     * @return int
289
+     */
290 290
     public function getErrorCode() : int
291 291
     {
292 292
         return $this->error['code'] ?? -1;
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
         // if the URL contains any URL characters, and we
115 115
         // do not want them URL encoded, restore them.
116
-        if(!$this->encodeUTF && !empty($this->unicodeChars))
116
+        if (!$this->encodeUTF && !empty($this->unicodeChars))
117 117
         {
118 118
             $this->info = $this->restoreUnicodeChars($this->info);
119 119
         }
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
         
131 131
         $keep = array();
132 132
         
133
-        foreach($chars as $char)
133
+        foreach ($chars as $char)
134 134
         {
135
-            if(preg_match('/\p{L}/uix', $char))
135
+            if (preg_match('/\p{L}/uix', $char))
136 136
             {
137 137
                 $encoded = rawurlencode($char);
138 138
                 
139
-                if($encoded !== $char)
139
+                if ($encoded !== $char)
140 140
                 {
141 141
                     $this->unicodeChars[$encoded] = $char;
142 142
                     $char = $encoded;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
     protected function detectType() : bool
153 153
     {
154
-        foreach(self::$detectorClasses as $className)
154
+        foreach (self::$detectorClasses as $className)
155 155
         {
156 156
             $detector = ClassHelper::requireObjectInstanceOf(
157 157
                 BaseURLTypeDetector::class,
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             // Use the adjusted data
164 164
             $this->info = $detector->getInfo();
165 165
 
166
-            if($detected) {
166
+            if ($detected) {
167 167
                 $this->isValid = true;
168 168
                 return true;
169 169
             }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
     protected function validate() : void
176 176
     {
177
-        foreach(self::$validatorClasses as $validatorClass)
177
+        foreach (self::$validatorClasses as $validatorClass)
178 178
         {
179 179
             $validator = ClassHelper::requireObjectInstanceOf(
180 180
                 BaseURLValidator::class,
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
             $this->info = $validator->getInfo();
187 187
 
188
-            if($result !== true) {
188
+            if ($result !== true) {
189 189
                 $this->isValid = false;
190 190
                 return;
191 191
             }
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
     {
216 216
         $result = array();
217 217
         
218
-        foreach($subject as $key => $val)
218
+        foreach ($subject as $key => $val)
219 219
         {
220
-            if(is_array($val))
220
+            if (is_array($val))
221 221
             {
222 222
                 $val = $this->restoreUnicodeChars($val);
223 223
             }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     */
244 244
     protected function restoreUnicodeChar(string $string) : string
245 245
     {
246
-        if(strpos($string, '%') !== false)
246
+        if (strpos($string, '%') !== false)
247 247
         {
248 248
             return str_replace(array_keys($this->unicodeChars), array_values($this->unicodeChars), $string);
249 249
         }
Please login to merge, or discard this patch.
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.
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.