@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | { |
| 14 | 14 | public function validate() : bool |
| 15 | 15 | { |
| 16 | - if(!$this->hasScheme() || URISchemes::isValidSchemeName((string)$this->getScheme())) { |
|
| 16 | + if (!$this->hasScheme() || URISchemes::isValidSchemeName((string)$this->getScheme())) { |
|
| 17 | 17 | return true; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | $this->parser->setError( |
| 23 | 23 | URLInfo::ERROR_INVALID_SCHEME, |
| 24 | - t('The scheme %1$s is not supported for links.', $this->getScheme()) . ' ' . |
|
| 24 | + t('The scheme %1$s is not supported for links.', $this->getScheme()).' '. |
|
| 25 | 25 | t('Valid schemes are: %1$s.', implode(', ', URISchemes::getSchemeNames())) |
| 26 | 26 | ); |
| 27 | 27 | |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public static function detectScheme(string $url) : ?string |
| 75 | 75 | { |
| 76 | - foreach(self::$schemes as $scheme) { |
|
| 77 | - if(stripos($url, $scheme) === 0) { |
|
| 76 | + foreach (self::$schemes as $scheme) { |
|
| 77 | + if (stripos($url, $scheme) === 0) { |
|
| 78 | 78 | return $scheme; |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -85,20 +85,20 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * @var string[]|null |
| 87 | 87 | */ |
| 88 | - private static ?array $schemeNames = null; |
|
| 88 | + private static ? array $schemeNames = null; |
|
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * @return string[] |
| 92 | 92 | */ |
| 93 | 93 | public static function getSchemeNames() : array |
| 94 | 94 | { |
| 95 | - if(isset(self::$schemeNames)) { |
|
| 95 | + if (isset(self::$schemeNames)) { |
|
| 96 | 96 | return self::$schemeNames; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | self::$schemeNames = array(); |
| 100 | 100 | |
| 101 | - foreach(self::$schemes as $scheme) { |
|
| 101 | + foreach (self::$schemes as $scheme) { |
|
| 102 | 102 | self::$schemeNames[] = self::resolveSchemeName($scheme); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | { |
| 132 | 132 | self::requireValidScheme($scheme); |
| 133 | 133 | |
| 134 | - if(!in_array($scheme, self::$schemes, true)) |
|
| 134 | + if (!in_array($scheme, self::$schemes, true)) |
|
| 135 | 135 | { |
| 136 | 136 | self::$schemes[] = $scheme; |
| 137 | 137 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | public static function requireValidScheme(string $scheme) : void |
| 143 | 143 | { |
| 144 | - if(strpos($scheme, ':')) |
|
| 144 | + if (strpos($scheme, ':')) |
|
| 145 | 145 | { |
| 146 | 146 | return; |
| 147 | 147 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @var array<string,string>|NULL |
| 71 | 71 | * @see URLInfo::getTypeLabel() |
| 72 | 72 | */ |
| 73 | - protected static ?array $typeLabels = null; |
|
| 73 | + protected static ? array $typeLabels = null; |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * @var bool |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | * @param bool $enabled |
| 134 | 134 | * @return URLInfo |
| 135 | 135 | */ |
| 136 | - public function setUTFEncoding(bool $enabled=true) : URLInfo |
|
| 136 | + public function setUTFEncoding(bool $enabled = true) : URLInfo |
|
| 137 | 137 | { |
| 138 | - if($this->encodeUTFChars !== $enabled) |
|
| 138 | + if ($this->encodeUTFChars !== $enabled) |
|
| 139 | 139 | { |
| 140 | 140 | $this->encodeUTFChars = $enabled; |
| 141 | 141 | $this->parse(); // reparse the URL to apply the changes |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | { |
| 240 | 240 | $port = $this->getInfoKey('port'); |
| 241 | 241 | |
| 242 | - if(!empty($port)) { |
|
| 242 | + if (!empty($port)) { |
|
| 243 | 243 | return (int)$port; |
| 244 | 244 | } |
| 245 | 245 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | protected function getInfoKey(string $name) : string |
| 321 | 321 | { |
| 322 | - if(isset($this->info[$name])) { |
|
| 322 | + if (isset($this->info[$name])) { |
|
| 323 | 323 | return (string)$this->info[$name]; |
| 324 | 324 | } |
| 325 | 325 | |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | return $this->normalize(false); |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - protected function normalize(bool $auth=true) : string |
|
| 351 | + protected function normalize(bool $auth = true) : string |
|
| 352 | 352 | { |
| 353 | - if(!$this->isValid()) { |
|
| 353 | + if (!$this->isValid()) { |
|
| 354 | 354 | return ''; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if(!isset($this->normalizer)) { |
|
| 357 | + if (!isset($this->normalizer)) { |
|
| 358 | 358 | $this->normalizer = new URINormalizer($this); |
| 359 | 359 | } |
| 360 | 360 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | public function getHighlighted() : string |
| 386 | 386 | { |
| 387 | - if(!$this->isValid()) { |
|
| 387 | + if (!$this->isValid()) { |
|
| 388 | 388 | return ''; |
| 389 | 389 | } |
| 390 | 390 | |
@@ -424,14 +424,14 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | public function getParams() : array |
| 426 | 426 | { |
| 427 | - if(!$this->paramExclusion || empty($this->excludedParams)) { |
|
| 427 | + if (!$this->paramExclusion || empty($this->excludedParams)) { |
|
| 428 | 428 | return $this->info['params']; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | $keep = array(); |
| 432 | - foreach($this->info['params'] as $name => $value) |
|
| 432 | + foreach ($this->info['params'] as $name => $value) |
|
| 433 | 433 | { |
| 434 | - if(!isset($this->excludedParams[$name])) { |
|
| 434 | + if (!isset($this->excludedParams[$name])) { |
|
| 435 | 435 | $keep[$name] = $value; |
| 436 | 436 | } |
| 437 | 437 | } |
@@ -470,9 +470,9 @@ discard block |
||
| 470 | 470 | * @param string $reason A human-readable explanation why this is excluded - used when highlighting links. |
| 471 | 471 | * @return URLInfo |
| 472 | 472 | */ |
| 473 | - public function excludeParam(string $name, string $reason='') : URLInfo |
|
| 473 | + public function excludeParam(string $name, string $reason = '') : URLInfo |
|
| 474 | 474 | { |
| 475 | - if(!isset($this->excludedParams[$name])) |
|
| 475 | + if (!isset($this->excludedParams[$name])) |
|
| 476 | 476 | { |
| 477 | 477 | $this->excludedParams[$name] = $reason; |
| 478 | 478 | $this->setParamExclusion(); |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | |
| 499 | 499 | public function getTypeLabel() : string |
| 500 | 500 | { |
| 501 | - if(!isset(self::$typeLabels)) |
|
| 501 | + if (!isset(self::$typeLabels)) |
|
| 502 | 502 | { |
| 503 | 503 | self::$typeLabels = array( |
| 504 | 504 | self::TYPE_EMAIL => t('Email'), |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | |
| 511 | 511 | $type = $this->getType(); |
| 512 | 512 | |
| 513 | - if(!isset(self::$typeLabels[$type])) |
|
| 513 | + if (!isset(self::$typeLabels[$type])) |
|
| 514 | 514 | { |
| 515 | 515 | throw new URLException( |
| 516 | 516 | sprintf('Unknown URL type label for type [%s].', $type), |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | * @param bool $highlight |
| 531 | 531 | * @return URLInfo |
| 532 | 532 | */ |
| 533 | - public function setHighlightExcluded(bool $highlight=true) : URLInfo |
|
| 533 | + public function setHighlightExcluded(bool $highlight = true) : URLInfo |
|
| 534 | 534 | { |
| 535 | 535 | $this->highlightExcluded = $highlight; |
| 536 | 536 | return $this; |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | * @see URLInfo::isParamExclusionEnabled() |
| 580 | 580 | * @see URLInfo::setHighlightExcluded() |
| 581 | 581 | */ |
| 582 | - public function setParamExclusion(bool $enabled=true) : URLInfo |
|
| 582 | + public function setParamExclusion(bool $enabled = true) : URLInfo |
|
| 583 | 583 | { |
| 584 | 584 | $this->paramExclusion = $enabled; |
| 585 | 585 | return $this; |
@@ -605,13 +605,13 @@ discard block |
||
| 605 | 605 | */ |
| 606 | 606 | public function containsExcludedParams() : bool |
| 607 | 607 | { |
| 608 | - if(empty($this->excludedParams)) { |
|
| 608 | + if (empty($this->excludedParams)) { |
|
| 609 | 609 | return false; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | $names = array_keys($this->info['params']); |
| 613 | - foreach($names as $name) { |
|
| 614 | - if(isset($this->excludedParams[$name])) { |
|
| 613 | + foreach ($names as $name) { |
|
| 614 | + if (isset($this->excludedParams[$name])) { |
|
| 615 | 615 | return true; |
| 616 | 616 | } |
| 617 | 617 | } |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | |
| 628 | 628 | public function offsetSet($offset, $value) : void |
| 629 | 629 | { |
| 630 | - if(in_array($offset, $this->infoKeys, true)) { |
|
| 630 | + if (in_array($offset, $this->infoKeys, true)) { |
|
| 631 | 631 | $this->info[$offset] = $value; |
| 632 | 632 | } |
| 633 | 633 | } |
@@ -644,11 +644,11 @@ discard block |
||
| 644 | 644 | |
| 645 | 645 | public function offsetGet($offset) |
| 646 | 646 | { |
| 647 | - if($offset === 'port') { |
|
| 647 | + if ($offset === 'port') { |
|
| 648 | 648 | return $this->getPort(); |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | - if(in_array($offset, $this->infoKeys, true)) { |
|
| 651 | + if (in_array($offset, $this->infoKeys, true)) { |
|
| 652 | 652 | return $this->getInfoKey($offset); |
| 653 | 653 | } |
| 654 | 654 | |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | * @param bool $verifySSL |
| 684 | 684 | * @return bool |
| 685 | 685 | */ |
| 686 | - public function tryConnect(bool $verifySSL=true) : bool |
|
| 686 | + public function tryConnect(bool $verifySSL = true) : bool |
|
| 687 | 687 | { |
| 688 | 688 | return $this->createConnectionTester() |
| 689 | 689 | ->setVerifySSL($verifySSL) |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | */ |
| 727 | 727 | public function removeParam(string $param) : URLInfo |
| 728 | 728 | { |
| 729 | - if(isset($this->info['params'][$param])) |
|
| 729 | + if (isset($this->info['params'][$param])) |
|
| 730 | 730 | { |
| 731 | 731 | unset($this->info['params'][$param]); |
| 732 | 732 | } |