Passed
Push — master ( b083ab...a3db06 )
by Sebastian
03:30
created
src/ClassHelper.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      *                         the vendor name, for example (Vendor\PackageName\Folder\Class).
42 42
      * @return string|null The detected class name, or NULL otherwise.
43 43
      */
44
-    public static function resolveClassName(string $legacyName, string $nsPrefix='') : ?string
44
+    public static function resolveClassName(string $legacyName, string $nsPrefix = '') : ?string
45 45
     {
46 46
         $names = array(
47 47
             str_replace('\\', '_', $legacyName),
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             $nsPrefix.'\\'.str_replace('_', '\\', $legacyName)
50 50
         );
51 51
 
52
-        foreach($names as $name) {
52
+        foreach ($names as $name) {
53 53
             if (class_exists($name)) {
54 54
                 return ltrim($name, '\\');
55 55
             }
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
      * @return string
69 69
      * @throws ClassNotExistsException
70 70
      */
71
-    public static function requireResolvedClass(string $legacyName, string $nsPrefix='') : string
71
+    public static function requireResolvedClass(string $legacyName, string $nsPrefix = '') : string
72 72
     {
73 73
         $class = self::resolveClassName($legacyName, $nsPrefix);
74 74
 
75
-        if($class !== null)
75
+        if ($class !== null)
76 76
         {
77 77
             return $class;
78 78
         }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public static function requireClassExists(string $className) : void
94 94
     {
95
-        if(class_exists($className))
95
+        if (class_exists($className))
96 96
         {
97 97
             return;
98 98
         }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         self::requireClassExists($targetClass);
118 118
         self::requireClassExists($extendsClass);
119 119
 
120
-        if(is_a($targetClass, $extendsClass, true))
120
+        if (is_a($targetClass, $extendsClass, true))
121 121
         {
122 122
             return;
123 123
         }
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
      * @throws ClassNotExistsException
143 143
      * @throws ClassNotImplementsException
144 144
      */
145
-    public static function requireObjectInstanceOf(string $class, object $object, int $errorCode=0)
145
+    public static function requireObjectInstanceOf(string $class, object $object, int $errorCode = 0)
146 146
     {
147
-        if($object instanceof Throwable)
147
+        if ($object instanceof Throwable)
148 148
         {
149 149
             throw new ClassNotExistsException(
150 150
                 $class,
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
             );
154 154
         }
155 155
 
156
-        if(!class_exists($class) && !interface_exists($class) && !trait_exists($class))
156
+        if (!class_exists($class) && !interface_exists($class) && !trait_exists($class))
157 157
         {
158 158
             throw new ClassNotExistsException($class, $errorCode);
159 159
         }
160 160
 
161
-        if(is_a($object, $class, true))
161
+        if (is_a($object, $class, true))
162 162
         {
163 163
             return $object;
164 164
         }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public static function getClassLoader() : ClassLoader
181 181
     {
182
-        if(isset(self::$classLoader)) {
182
+        if (isset(self::$classLoader)) {
183 183
             return self::$classLoader;
184 184
         }
185 185
 
@@ -193,14 +193,14 @@  discard block
 block discarded – undo
193 193
 
194 194
         $autoloadFile = null;
195 195
 
196
-        foreach($paths as $path)
196
+        foreach ($paths as $path)
197 197
         {
198
-            if(file_exists($path)) {
198
+            if (file_exists($path)) {
199 199
                 $autoloadFile = $path;
200 200
             }
201 201
         }
202 202
 
203
-        if($autoloadFile === null) {
203
+        if ($autoloadFile === null) {
204 204
             throw new ClassLoaderNotFoundException($paths);
205 205
         }
206 206
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     private static function splitClass($subject) : array
253 253
     {
254
-        if(is_object($subject)) {
254
+        if (is_object($subject)) {
255 255
             $class = get_class($subject);
256 256
         } else {
257 257
             $class = $subject;
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,11 +194,11 @@  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['params'] = array();
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
         }
253 253
     }
254 254
     
255
-   /**
256
-    * Recursively goes through the array, and converts all previously
257
-    * URL encoded characters with their unicode character counterparts.
258
-    * 
259
-    * @param array $subject
260
-    * @return array
261
-    */
255
+    /**
256
+     * Recursively goes through the array, and converts all previously
257
+     * URL encoded characters with their unicode character counterparts.
258
+     * 
259
+     * @param array $subject
260
+     * @return array
261
+     */
262 262
     protected function restoreUnicodeChars(array $subject) : array
263 263
     {
264 264
         $result = array();
@@ -282,13 +282,13 @@  discard block
 block discarded – undo
282 282
         return $result;
283 283
     }
284 284
     
285
-   /**
286
-    * Replaces all URL encoded unicode characters
287
-    * in the string with the unicode character.
288
-    * 
289
-    * @param string $string
290
-    * @return string
291
-    */
285
+    /**
286
+     * Replaces all URL encoded unicode characters
287
+     * in the string with the unicode character.
288
+     * 
289
+     * @param string $string
290
+     * @return string
291
+     */
292 292
     protected function restoreUnicodeChar(string $string) : string
293 293
     {
294 294
         if(strpos($string, '%') !== false)
@@ -309,32 +309,32 @@  discard block
 block discarded – undo
309 309
         );
310 310
     }
311 311
    
312
-   /**
313
-    * Checks whether the URL that was parsed is valid.
314
-    * @return bool
315
-    */
312
+    /**
313
+     * Checks whether the URL that was parsed is valid.
314
+     * @return bool
315
+     */
316 316
     public function isValid() : bool
317 317
     {
318 318
         return $this->isValid;
319 319
     }
320 320
 
321
-   /**
322
-    * If the validation failed, retrieves the validation
323
-    * error message.
324
-    * 
325
-    * @return string
326
-    */
321
+    /**
322
+     * If the validation failed, retrieves the validation
323
+     * error message.
324
+     * 
325
+     * @return string
326
+     */
327 327
     public function getErrorMessage() : string
328 328
     {
329 329
         return $this->error['message'] ?? '';
330 330
     }
331 331
     
332
-   /**
333
-    * If the validation failed, retrieves the validation
334
-    * error code.
335
-    * 
336
-    * @return int
337
-    */
332
+    /**
333
+     * If the validation failed, retrieves the validation
334
+     * error code.
335
+     * 
336
+     * @return int
337
+     */
338 338
     public function getErrorCode() : int
339 339
     {
340 340
         return $this->error['code'] ?? -1;
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 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
             }
@@ -204,48 +204,48 @@  discard block
 block discarded – undo
204 204
         $this->info['params'] = array();
205 205
         $this->info['type'] = URLInfo::TYPE_NONE;
206 206
 
207
-        if($this->hasScheme())
207
+        if ($this->hasScheme())
208 208
         {
209 209
             $this->setScheme(strtolower($this->getScheme()));
210 210
         }
211 211
         else
212 212
         {
213 213
             $scheme = URISchemes::detectScheme($this->url);
214
-            if(!empty($scheme)) {
214
+            if (!empty($scheme)) {
215 215
                 $this->setScheme(URISchemes::resolveSchemeName($scheme));
216 216
             }
217 217
         }
218 218
 
219
-        if(isset($this->info['user'])) {
219
+        if (isset($this->info['user'])) {
220 220
             $this->info['user'] = urldecode($this->info['user']);
221 221
         }
222 222
 
223
-        if(isset($this->info['pass'])) {
223
+        if (isset($this->info['pass'])) {
224 224
             $this->info['pass'] = urldecode($this->info['pass']);
225 225
         }
226 226
         
227
-        if($this->hasHost()) {
227
+        if ($this->hasHost()) {
228 228
             $host = $this->getHost();
229 229
             $host = strtolower($host);
230 230
             $host = str_replace(' ', '', $host);
231 231
             $this->setHost($host);
232 232
         }
233 233
         
234
-        if($this->hasPath()) {
234
+        if ($this->hasPath()) {
235 235
             $this->setPath(str_replace(' ', '', $this->getPath()));
236 236
         }
237 237
 
238
-        if($this->getPath() === 'localhost')
238
+        if ($this->getPath() === 'localhost')
239 239
         {
240 240
             $this->setHost('localhost');
241 241
             $this->removePath();
242 242
 
243
-            if(!$this->hasScheme()) {
243
+            if (!$this->hasScheme()) {
244 244
                 $this->setSchemeHTTPS();
245 245
             }
246 246
         }
247 247
 
248
-        if(isset($this->info['query']) && !empty($this->info['query']))
248
+        if (isset($this->info['query']) && !empty($this->info['query']))
249 249
         {
250 250
             $this->info['params'] = ConvertHelper::parseQueryString($this->info['query']);
251 251
             ksort($this->info['params']);
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
     {
264 264
         $result = array();
265 265
         
266
-        foreach($subject as $key => $val)
266
+        foreach ($subject as $key => $val)
267 267
         {
268
-            if(is_array($val))
268
+            if (is_array($val))
269 269
             {
270 270
                 $val = $this->restoreUnicodeChars($val);
271 271
             }
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
     */
292 292
     protected function restoreUnicodeChar(string $string) : string
293 293
     {
294
-        if(strpos($string, '%') !== false)
294
+        if (strpos($string, '%') !== false)
295 295
         {
296 296
             return str_replace(array_keys($this->unicodeChars), array_values($this->unicodeChars), $string);
297 297
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -207,8 +207,7 @@  discard block
 block discarded – undo
207 207
         if($this->hasScheme())
208 208
         {
209 209
             $this->setScheme(strtolower($this->getScheme()));
210
-        }
211
-        else
210
+        } else
212 211
         {
213 212
             $scheme = URISchemes::detectScheme($this->url);
214 213
             if(!empty($scheme)) {
@@ -268,8 +267,7 @@  discard block
 block discarded – undo
268 267
             if(is_array($val))
269 268
             {
270 269
                 $val = $this->restoreUnicodeChars($val);
271
-            }
272
-            else
270
+            } else
273 271
             {
274 272
                 $val = $this->restoreUnicodeChar($val);
275 273
             }
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($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.
src/URLInfo/Parser/URLTypeDetector/DetectStandardURL.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 {
11 11
     public function detect() : bool
12 12
     {
13
-        if($this->hasHost() || $this->hasQuery() || $this->hasScheme()) {
13
+        if ($this->hasHost() || $this->hasQuery() || $this->hasScheme()) {
14 14
             $this->setTypeURL();
15 15
             return true;
16 16
         }
Please login to merge, or discard this patch.
src/URLInfo/Parser/URLTypeDetector/DetectFragmentLink.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 {
12 12
     public function detect() : bool
13 13
     {
14
-        if($this->hasFragment() && (!$this->hasScheme() && !$this->hasHost() && !$this->hasQuery() && !$this->hasPath())) {
14
+        if ($this->hasFragment() && (!$this->hasScheme() && !$this->hasHost() && !$this->hasQuery() && !$this->hasPath())) {
15 15
             $this->setTypeFragment();
16 16
             return true;
17 17
         }
Please login to merge, or discard this patch.
src/URLInfo/Parser/URLTypeDetector/DetectIPAddress.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 {
12 12
     public function detect() : bool
13 13
     {
14
-        if(!$this->hasHost() && $this->hasPath() && preg_match(RegexHelper::REGEX_IPV4, $this->getPath())) {
14
+        if (!$this->hasHost() && $this->hasPath() && preg_match(RegexHelper::REGEX_IPV4, $this->getPath())) {
15 15
             $this
16 16
                 ->setHost($this->getPath())
17 17
                 ->setSchemeHTTPS()
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
             return true;
23 23
         }
24 24
 
25
-        if($this->hasHost() && preg_match(RegexHelper::REGEX_IPV4, $this->getHost())) {
25
+        if ($this->hasHost() && preg_match(RegexHelper::REGEX_IPV4, $this->getHost())) {
26 26
             $this->setIP($this->getHost());
27 27
             $this->setTypeURL();
28 28
             return true;
Please login to merge, or discard this patch.
src/URLInfo/Parser/URLTypeDetector/DetectPhoneLink.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 {
12 12
     public function detect() : bool
13 13
     {
14
-        if($this->getScheme() === 'tel') {
14
+        if ($this->getScheme() === 'tel') {
15 15
             $this->setTypePhone();
16 16
             return true;
17 17
         }
Please login to merge, or discard this patch.
src/URLInfo/Parser/URLValidator/ValidateHostIsPresent.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@
 block discarded – undo
15 15
         // every link needs a host. This case can happen for ex, if
16 16
         // the link starts with a typo with only one slash, like:
17 17
         // "http:/hostname"
18
-        if($this->hasHost() || $this->isSchemeLess()) {
18
+        if ($this->hasHost() || $this->isSchemeLess()) {
19 19
             return true;
20 20
         }
21 21
 
22 22
         $this->parser->setError(
23 23
             URLInfo::ERROR_MISSING_HOST,
24
-            t('Cannot determine the link\'s host name.') . ' ' .
24
+            t('Cannot determine the link\'s host name.').' '.
25 25
             t('This usually happens when there\'s a typo somewhere.')
26 26
         );
27 27
 
Please login to merge, or discard this patch.
src/URLInfo/Parser/URLValidator/ValidateIsTypeKnown.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 {
13 13
     public function validate() : bool
14 14
     {
15
-        if($this->getType() !== URLInfo::TYPE_NONE)
15
+        if ($this->getType() !== URLInfo::TYPE_NONE)
16 16
         {
17 17
             return true;
18 18
         }
Please login to merge, or discard this patch.