@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param bool $enabled |
| 107 | 107 | * @return $this |
| 108 | 108 | */ |
| 109 | - public function enableNormalizing(bool $enabled=true) : ConvertHelper_URLFinder |
|
| 109 | + public function enableNormalizing(bool $enabled = true) : ConvertHelper_URLFinder |
|
| 110 | 110 | { |
| 111 | 111 | $this->setOption('normalize', $enabled); |
| 112 | 112 | return $this; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * @param bool $enabled |
| 119 | 119 | * @return $this |
| 120 | 120 | */ |
| 121 | - public function enableSorting(bool $enabled=true) : ConvertHelper_URLFinder |
|
| 121 | + public function enableSorting(bool $enabled = true) : ConvertHelper_URLFinder |
|
| 122 | 122 | { |
| 123 | 123 | $this->setOption('sorting', $enabled); |
| 124 | 124 | return $this; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @param bool $include |
| 133 | 133 | * @return ConvertHelper_URLFinder |
| 134 | 134 | */ |
| 135 | - public function includeEmails(bool $include=true) : ConvertHelper_URLFinder |
|
| 135 | + public function includeEmails(bool $include = true) : ConvertHelper_URLFinder |
|
| 136 | 136 | { |
| 137 | 137 | $this->setOption('include-emails', $include); |
| 138 | 138 | return $this; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param bool $omit |
| 145 | 145 | * @return ConvertHelper_URLFinder |
| 146 | 146 | */ |
| 147 | - public function omitMailto(bool $omit=true) : ConvertHelper_URLFinder |
|
| 147 | + public function omitMailto(bool $omit = true) : ConvertHelper_URLFinder |
|
| 148 | 148 | { |
| 149 | 149 | $this->setOption('omit-mailto', $omit); |
| 150 | 150 | return $this; |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | $line = $this->analyzeLine($line); |
| 173 | 173 | |
| 174 | - if($line !== null) { |
|
| 174 | + if ($line !== null) { |
|
| 175 | 175 | $keep[] = $line; |
| 176 | 176 | } |
| 177 | 177 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $line = trim($line, '.'); |
| 193 | 193 | |
| 194 | 194 | // Handle detecting an URI scheme |
| 195 | - if(strstr($line, ':') !== false) |
|
| 195 | + if (strstr($line, ':') !== false) |
|
| 196 | 196 | { |
| 197 | 197 | $scheme = URISchemes::detectScheme($line); |
| 198 | 198 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | // detect are email addresses and domain names. |
| 207 | 207 | |
| 208 | 208 | // No dot? Then it's certainly not a domain name. |
| 209 | - if(strstr($line, '.') === false) { |
|
| 209 | + if (strstr($line, '.') === false) { |
|
| 210 | 210 | return null; |
| 211 | 211 | } |
| 212 | 212 | |
@@ -224,10 +224,10 @@ discard block |
||
| 224 | 224 | { |
| 225 | 225 | $subject = stripslashes($subject); |
| 226 | 226 | |
| 227 | - foreach($this->detectors as $detector) |
|
| 227 | + foreach ($this->detectors as $detector) |
|
| 228 | 228 | { |
| 229 | 229 | // Avoid processing the string if it is not needed. |
| 230 | - if($detector->getRunPosition() !== ConvertHelper_URLFinder_Detector::RUN_BEFORE || !$detector->isValidFor($subject)) { |
|
| 230 | + if ($detector->getRunPosition() !== ConvertHelper_URLFinder_Detector::RUN_BEFORE || !$detector->isValidFor($subject)) { |
|
| 231 | 231 | continue; |
| 232 | 232 | } |
| 233 | 233 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | { |
| 249 | 249 | $detector = new $className(); |
| 250 | 250 | |
| 251 | - if($detector instanceof ConvertHelper_URLFinder_Detector) |
|
| 251 | + if ($detector instanceof ConvertHelper_URLFinder_Detector) |
|
| 252 | 252 | { |
| 253 | 253 | return $detector; |
| 254 | 254 | } |
@@ -275,12 +275,12 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | $result = $this->getItemsAsString($this->urls); |
| 277 | 277 | |
| 278 | - if($this->getBoolOption('include-emails')) |
|
| 278 | + if ($this->getBoolOption('include-emails')) |
|
| 279 | 279 | { |
| 280 | 280 | $result = array_merge($result, $this->getEmails()); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if($this->getBoolOption('sorting')) |
|
| 283 | + if ($this->getBoolOption('sorting')) |
|
| 284 | 284 | { |
| 285 | 285 | usort($result, function(string $a, string $b) { |
| 286 | 286 | return strnatcasecmp($a, $b); |
@@ -300,12 +300,12 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | $result = array(); |
| 302 | 302 | |
| 303 | - foreach($collection as $url => $info) { |
|
| 304 | - if($normalize) { |
|
| 303 | + foreach ($collection as $url => $info) { |
|
| 304 | + if ($normalize) { |
|
| 305 | 305 | $url = $info->getNormalized(); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - if(!in_array($url, $result)) { |
|
| 308 | + if (!in_array($url, $result)) { |
|
| 309 | 309 | $result[] = $url; |
| 310 | 310 | } |
| 311 | 311 | } |
@@ -322,9 +322,9 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | private function initDetectors() : void |
| 324 | 324 | { |
| 325 | - foreach($this->enabledDetectorClasses as $className => $enabled) |
|
| 325 | + foreach ($this->enabledDetectorClasses as $className => $enabled) |
|
| 326 | 326 | { |
| 327 | - if($enabled) { |
|
| 327 | + if ($enabled) { |
|
| 328 | 328 | $this->detectors[] = $this->createDetector($className); |
| 329 | 329 | } |
| 330 | 330 | } |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | private function parse() : void |
| 341 | 341 | { |
| 342 | - if($this->parsed) { |
|
| 342 | + if ($this->parsed) { |
|
| 343 | 343 | return; |
| 344 | 344 | } |
| 345 | 345 | |
@@ -350,11 +350,11 @@ discard block |
||
| 350 | 350 | |
| 351 | 351 | unset($this->subject); |
| 352 | 352 | |
| 353 | - foreach($this->matches as $match) |
|
| 353 | + foreach ($this->matches as $match) |
|
| 354 | 354 | { |
| 355 | 355 | $info = parseURL($match); |
| 356 | 356 | |
| 357 | - if($info->isEmail()) |
|
| 357 | + if ($info->isEmail()) |
|
| 358 | 358 | { |
| 359 | 359 | $this->emails[$this->filterEmailAddress($match)] = $info; |
| 360 | 360 | continue; |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | * @param bool $enable |
| 371 | 371 | * @return $this |
| 372 | 372 | */ |
| 373 | - public function enableHTMLAttributes(bool $enable=true) : ConvertHelper_URLFinder |
|
| 373 | + public function enableHTMLAttributes(bool $enable = true) : ConvertHelper_URLFinder |
|
| 374 | 374 | { |
| 375 | 375 | $this->enabledDetectorClasses[ConvertHelper_URLFinder_Detector_HTMLAttributes::class] = $enable; |
| 376 | 376 | return $this; |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | */ |
| 386 | 386 | private function filterEmailAddress(string $email) : string |
| 387 | 387 | { |
| 388 | - if(stristr($email, 'mailto:') === false) { |
|
| 388 | + if (stristr($email, 'mailto:') === false) { |
|
| 389 | 389 | $email = 'mailto:'.$email; |
| 390 | 390 | } |
| 391 | 391 | |
@@ -407,14 +407,14 @@ discard block |
||
| 407 | 407 | foreach ($lines as $line) |
| 408 | 408 | { |
| 409 | 409 | $scheme = URISchemes::detectScheme($line); |
| 410 | - if($scheme !== null) { |
|
| 410 | + if ($scheme !== null) { |
|
| 411 | 411 | $this->matches[] = $line; |
| 412 | 412 | continue; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | $extension = $this->detectDomainExtension($line); |
| 416 | 416 | |
| 417 | - if($domains->nameExists($extension)) { |
|
| 417 | + if ($domains->nameExists($extension)) { |
|
| 418 | 418 | $this->matches[] = $line; |
| 419 | 419 | } |
| 420 | 420 | } |
@@ -433,9 +433,9 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | $subject = str_replace($remove, ' ', $subject); |
| 435 | 435 | |
| 436 | - foreach($this->detectors as $detector) |
|
| 436 | + foreach ($this->detectors as $detector) |
|
| 437 | 437 | { |
| 438 | - if($detector->getRunPosition() !== ConvertHelper_URLFinder_Detector::RUN_AFTER || !$detector->isValidFor($subject)) { |
|
| 438 | + if ($detector->getRunPosition() !== ConvertHelper_URLFinder_Detector::RUN_AFTER || !$detector->isValidFor($subject)) { |
|
| 439 | 439 | continue; |
| 440 | 440 | } |
| 441 | 441 | |
@@ -458,8 +458,8 @@ discard block |
||
| 458 | 458 | $boundaries = array('/', '?'); |
| 459 | 459 | |
| 460 | 460 | // Remove the path or query parts to access the domain extension only |
| 461 | - foreach($boundaries as $boundary) { |
|
| 462 | - if(strstr($url, $boundary)) { |
|
| 461 | + foreach ($boundaries as $boundary) { |
|
| 462 | + if (strstr($url, $boundary)) { |
|
| 463 | 463 | $parts = explode($boundary, $url); |
| 464 | 464 | $url = array_shift($parts); |
| 465 | 465 | break; |
@@ -484,16 +484,16 @@ discard block |
||
| 484 | 484 | |
| 485 | 485 | $result = $this->getItemsAsString($this->emails); |
| 486 | 486 | |
| 487 | - if($this->getBoolOption('omit-mailto')) { |
|
| 487 | + if ($this->getBoolOption('omit-mailto')) { |
|
| 488 | 488 | $keep = array(); |
| 489 | - foreach($result as $email) { |
|
| 489 | + foreach ($result as $email) { |
|
| 490 | 490 | $keep[] = str_replace('mailto:', '', $email); |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | $result = $keep; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - if($this->getBoolOption('sorting')) |
|
| 496 | + if ($this->getBoolOption('sorting')) |
|
| 497 | 497 | { |
| 498 | 498 | usort($result, function(string $a, string $b) { |
| 499 | 499 | return strnatcasecmp($a, $b); |
@@ -515,16 +515,16 @@ discard block |
||
| 515 | 515 | $result = array(); |
| 516 | 516 | $normalize = $this->getBoolOption('normalize'); |
| 517 | 517 | |
| 518 | - foreach($this->urls as $url => $info) |
|
| 518 | + foreach ($this->urls as $url => $info) |
|
| 519 | 519 | { |
| 520 | - if($normalize) { |
|
| 520 | + if ($normalize) { |
|
| 521 | 521 | $url = $info->getNormalized(); |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | $result[$url] = $info; |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | - if($this->getBoolOption('sorting')) |
|
| 527 | + if ($this->getBoolOption('sorting')) |
|
| 528 | 528 | { |
| 529 | 529 | ksort($result); |
| 530 | 530 | } |
@@ -42,18 +42,18 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -113,7 +113,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -207,8 +207,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -22,13 +22,13 @@ |
||
| 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(); |
@@ -10,7 +10,7 @@ |
||
| 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 | } |
@@ -11,7 +11,7 @@ |
||
| 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 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 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 |
||
| 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; |
@@ -11,7 +11,7 @@ |
||
| 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 | } |
@@ -15,13 +15,13 @@ |
||
| 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 | |
@@ -12,7 +12,7 @@ |
||
| 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 | } |