@@ -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 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | { |
| 13 | 13 | public function validate() : bool |
| 14 | 14 | { |
| 15 | - if($this->hasScheme() || $this->isFragmentOnly()) { |
|
| 15 | + if ($this->hasScheme() || $this->isFragmentOnly()) { |
|
| 16 | 16 | return true; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -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 | } |
@@ -28,23 +28,23 @@ |
||
| 28 | 28 | $this->info = $info; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Enables the authentication information in the URL, |
|
| 33 | - * if a username and password are present. |
|
| 34 | - * |
|
| 35 | - * @param bool $enable Whether to turn it on or off. |
|
| 36 | - * @return URINormalizer |
|
| 37 | - */ |
|
| 31 | + /** |
|
| 32 | + * Enables the authentication information in the URL, |
|
| 33 | + * if a username and password are present. |
|
| 34 | + * |
|
| 35 | + * @param bool $enable Whether to turn it on or off. |
|
| 36 | + * @return URINormalizer |
|
| 37 | + */ |
|
| 38 | 38 | public function enableAuth(bool $enable=true) : URINormalizer |
| 39 | 39 | { |
| 40 | 40 | $this->auth = $enable; |
| 41 | 41 | return $this; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Retrieves the normalized URL. |
|
| 46 | - * @return string |
|
| 47 | - */ |
|
| 44 | + /** |
|
| 45 | + * Retrieves the normalized URL. |
|
| 46 | + * @return string |
|
| 47 | + */ |
|
| 48 | 48 | public function normalize() : string |
| 49 | 49 | { |
| 50 | 50 | $method = 'normalize_'.$this->info->getType(); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param bool $enable Whether to turn it on or off. |
| 36 | 36 | * @return URINormalizer |
| 37 | 37 | */ |
| 38 | - public function enableAuth(bool $enable=true) : URINormalizer |
|
| 38 | + public function enableAuth(bool $enable = true) : URINormalizer |
|
| 39 | 39 | { |
| 40 | 40 | $this->auth = $enable; |
| 41 | 41 | return $this; |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | $scheme = $this->info->getScheme(); |
| 73 | 73 | $normalized = ''; |
| 74 | 74 | |
| 75 | - if(!empty($scheme)) |
|
| 75 | + if (!empty($scheme)) |
|
| 76 | 76 | { |
| 77 | - $normalized = $this->info->getScheme() . '://'; |
|
| 77 | + $normalized = $this->info->getScheme().'://'; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $normalized = $this->renderAuth($normalized); |
@@ -89,48 +89,48 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | protected function renderAuth(string $normalized) : string |
| 91 | 91 | { |
| 92 | - if(!$this->auth || !$this->info->hasUsername()) { |
|
| 92 | + if (!$this->auth || !$this->info->hasUsername()) { |
|
| 93 | 93 | return $normalized; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - return $normalized . urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@'; |
|
| 96 | + return $normalized.urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@'; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | protected function renderPort(string $normalized) : string |
| 100 | 100 | { |
| 101 | - if(!$this->info->hasPort()) { |
|
| 101 | + if (!$this->info->hasPort()) { |
|
| 102 | 102 | return $normalized; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - return $normalized . ':'.$this->info->getPort(); |
|
| 105 | + return $normalized.':'.$this->info->getPort(); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | protected function renderPath(string $normalized) : string |
| 109 | 109 | { |
| 110 | - if(!$this->info->hasPath()) { |
|
| 110 | + if (!$this->info->hasPath()) { |
|
| 111 | 111 | return $normalized; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - return $normalized . $this->info->getPath(); |
|
| 114 | + return $normalized.$this->info->getPath(); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | protected function renderParams(string $normalized) : string |
| 118 | 118 | { |
| 119 | 119 | $params = $this->info->getParams(); |
| 120 | 120 | |
| 121 | - if(empty($params)) { |
|
| 121 | + if (empty($params)) { |
|
| 122 | 122 | return $normalized; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - return $normalized . '?'.http_build_query($params, '', '&', PHP_QUERY_RFC3986); |
|
| 125 | + return $normalized.'?'.http_build_query($params, '', '&', PHP_QUERY_RFC3986); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | protected function renderFragment(string $normalized) : string |
| 129 | 129 | { |
| 130 | - if(!$this->info->hasFragment()) { |
|
| 130 | + if (!$this->info->hasFragment()) { |
|
| 131 | 131 | return $normalized; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - return $normalized . '#'.$this->info->getFragment(); |
|
| 134 | + return $normalized.'#'.$this->info->getFragment(); |
|
| 135 | 135 | } |
| 136 | 136 | } |
@@ -155,13 +155,13 @@ |
||
| 155 | 155 | ); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Fetches all parameters in the URL, regardless of |
|
| 160 | - * whether parameter exclusion is enabled, so they |
|
| 161 | - * can be highlighted is need be. |
|
| 162 | - * |
|
| 163 | - * @return array<string,string> |
|
| 164 | - */ |
|
| 158 | + /** |
|
| 159 | + * Fetches all parameters in the URL, regardless of |
|
| 160 | + * whether parameter exclusion is enabled, so they |
|
| 161 | + * can be highlighted is need be. |
|
| 162 | + * |
|
| 163 | + * @return array<string,string> |
|
| 164 | + */ |
|
| 165 | 165 | protected function resolveParams() : array |
| 166 | 166 | { |
| 167 | 167 | $previous = $this->info->isParamExclusionEnabled(); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | 'fragment' |
| 75 | 75 | ); |
| 76 | 76 | |
| 77 | - foreach($parts as $part) |
|
| 77 | + foreach ($parts as $part) |
|
| 78 | 78 | { |
| 79 | 79 | $method = 'render_'.$part; |
| 80 | 80 | $result[] = (string)$this->$method(); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | protected function render_scheme() : string |
| 87 | 87 | { |
| 88 | - if(!$this->info->hasScheme()) { |
|
| 88 | + if (!$this->info->hasScheme()) { |
|
| 89 | 89 | return ''; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | protected function render_username() : string |
| 102 | 102 | { |
| 103 | - if(!$this->info->hasUsername()) { |
|
| 103 | + if (!$this->info->hasUsername()) { |
|
| 104 | 104 | return ''; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | protected function render_host() : string |
| 118 | 118 | { |
| 119 | - if(!$this->info->hasHost()) { |
|
| 119 | + if (!$this->info->hasHost()) { |
|
| 120 | 120 | return ''; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | protected function render_port() : string |
| 130 | 130 | { |
| 131 | - if(!$this->info->hasPort()) { |
|
| 131 | + if (!$this->info->hasPort()) { |
|
| 132 | 132 | return ''; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | protected function render_path() : string |
| 143 | 143 | { |
| 144 | - if(!$this->info->hasPath()) { |
|
| 144 | + if (!$this->info->hasPath()) { |
|
| 145 | 145 | return ''; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | { |
| 167 | 167 | $previous = $this->info->isParamExclusionEnabled(); |
| 168 | 168 | |
| 169 | - if($previous) |
|
| 169 | + if ($previous) |
|
| 170 | 170 | { |
| 171 | 171 | $this->info->setParamExclusion(false); |
| 172 | 172 | } |
@@ -182,19 +182,19 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | $params = $this->resolveParams(); |
| 184 | 184 | |
| 185 | - if(empty($params)) { |
|
| 185 | + if (empty($params)) { |
|
| 186 | 186 | return ''; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $tokens = array(); |
| 190 | 190 | $excluded = array(); |
| 191 | 191 | |
| 192 | - if($this->info->isParamExclusionEnabled()) |
|
| 192 | + if ($this->info->isParamExclusionEnabled()) |
|
| 193 | 193 | { |
| 194 | 194 | $excluded = $this->info->getExcludedParams(); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - foreach($params as $param => $value) |
|
| 197 | + foreach ($params as $param => $value) |
|
| 198 | 198 | { |
| 199 | 199 | // If the parameter is numeric, it will automatically |
| 200 | 200 | // be an integer, so we need the conversion here. |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | $tag = $this->resolveTag($excluded, $param); |
| 217 | 217 | |
| 218 | - if(!empty($tag)) |
|
| 218 | + if (!empty($tag)) |
|
| 219 | 219 | { |
| 220 | 220 | $tokens[] = sprintf($tag, $parts); |
| 221 | 221 | } |
@@ -234,13 +234,13 @@ discard block |
||
| 234 | 234 | protected function resolveTag(array $excluded, string $paramName) : string |
| 235 | 235 | { |
| 236 | 236 | // regular, non-excluded parameter |
| 237 | - if(!isset($excluded[$paramName])) |
|
| 237 | + if (!isset($excluded[$paramName])) |
|
| 238 | 238 | { |
| 239 | 239 | return '<span class="link-param">%s</span>'; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | // highlight excluded parameters is disabled, ignore this parameter |
| 243 | - if(!$this->info->isHighlightExcludeEnabled()) |
|
| 243 | + if (!$this->info->isHighlightExcludeEnabled()) |
|
| 244 | 244 | { |
| 245 | 245 | return ''; |
| 246 | 246 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | protected function render_fragment() : string |
| 258 | 258 | { |
| 259 | - if(!$this->info->hasFragment()) { |
|
| 259 | + if (!$this->info->hasFragment()) { |
|
| 260 | 260 | return ''; |
| 261 | 261 | } |
| 262 | 262 | |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | { |
| 272 | 272 | $cssFolder = realpath(__DIR__.'/../../css'); |
| 273 | 273 | |
| 274 | - if($cssFolder === false) { |
|
| 274 | + if ($cssFolder === false) { |
|
| 275 | 275 | throw new URLException( |
| 276 | 276 | 'Cannot find package CSS folder.', |
| 277 | 277 | null, |
@@ -44,42 +44,42 @@ discard block |
||
| 44 | 44 | public const TYPE_URL = 'url'; |
| 45 | 45 | public const TYPE_NONE = 'none'; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * The original URL that was passed to the constructor. |
|
| 49 | - * @var string |
|
| 50 | - */ |
|
| 47 | + /** |
|
| 48 | + * The original URL that was passed to the constructor. |
|
| 49 | + * @var string |
|
| 50 | + */ |
|
| 51 | 51 | protected string $rawURL; |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @var array<string,mixed> |
|
| 55 | - */ |
|
| 53 | + /** |
|
| 54 | + * @var array<string,mixed> |
|
| 55 | + */ |
|
| 56 | 56 | protected array $info; |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @var string[] |
|
| 60 | - */ |
|
| 58 | + /** |
|
| 59 | + * @var string[] |
|
| 60 | + */ |
|
| 61 | 61 | protected array $excludedParams = array(); |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @var bool |
|
| 65 | - * @see URLInfo::setParamExclusion() |
|
| 66 | - */ |
|
| 63 | + /** |
|
| 64 | + * @var bool |
|
| 65 | + * @see URLInfo::setParamExclusion() |
|
| 66 | + */ |
|
| 67 | 67 | protected bool $paramExclusion = false; |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @var array<string,string>|NULL |
|
| 71 | - * @see URLInfo::getTypeLabel() |
|
| 72 | - */ |
|
| 69 | + /** |
|
| 70 | + * @var array<string,string>|NULL |
|
| 71 | + * @see URLInfo::getTypeLabel() |
|
| 72 | + */ |
|
| 73 | 73 | protected static ?array $typeLabels = null; |
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @var bool |
|
| 77 | - */ |
|
| 75 | + /** |
|
| 76 | + * @var bool |
|
| 77 | + */ |
|
| 78 | 78 | protected bool $highlightExcluded = false; |
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @var string[] |
|
| 82 | - */ |
|
| 80 | + /** |
|
| 81 | + * @var string[] |
|
| 82 | + */ |
|
| 83 | 83 | protected array $infoKeys = array( |
| 84 | 84 | 'scheme', |
| 85 | 85 | 'host', |
@@ -91,24 +91,24 @@ discard block |
||
| 91 | 91 | 'fragment' |
| 92 | 92 | ); |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @var string |
|
| 96 | - */ |
|
| 94 | + /** |
|
| 95 | + * @var string |
|
| 96 | + */ |
|
| 97 | 97 | protected string $url; |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * @var URIParser |
|
| 101 | - */ |
|
| 99 | + /** |
|
| 100 | + * @var URIParser |
|
| 101 | + */ |
|
| 102 | 102 | protected URIParser $parser; |
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * @var URINormalizer|NULL |
|
| 106 | - */ |
|
| 104 | + /** |
|
| 105 | + * @var URINormalizer|NULL |
|
| 106 | + */ |
|
| 107 | 107 | protected ?URINormalizer $normalizer = null; |
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * @var bool |
|
| 111 | - */ |
|
| 109 | + /** |
|
| 110 | + * @var bool |
|
| 111 | + */ |
|
| 112 | 112 | protected bool $encodeUTFChars = false; |
| 113 | 113 | |
| 114 | 114 | public function __construct(string $url) |
@@ -125,14 +125,14 @@ discard block |
||
| 125 | 125 | $this->info = $this->parser->getInfo(); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * Whether to URL encode any non-encoded UTF8 characters in the URL. |
|
| 130 | - * Default is to leave them as-is for better readability, since |
|
| 131 | - * browsers handle this well. |
|
| 132 | - * |
|
| 133 | - * @param bool $enabled |
|
| 134 | - * @return URLInfo |
|
| 135 | - */ |
|
| 128 | + /** |
|
| 129 | + * Whether to URL encode any non-encoded UTF8 characters in the URL. |
|
| 130 | + * Default is to leave them as-is for better readability, since |
|
| 131 | + * browsers handle this well. |
|
| 132 | + * |
|
| 133 | + * @param bool $enabled |
|
| 134 | + * @return URLInfo |
|
| 135 | + */ |
|
| 136 | 136 | public function setUTFEncoding(bool $enabled=true) : URLInfo |
| 137 | 137 | { |
| 138 | 138 | if($this->encodeUTFChars !== $enabled) |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | return $this->encodeUTFChars; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Filters a URL: removes control characters and the |
|
| 154 | - * like to have a clean URL to work with. |
|
| 155 | - * |
|
| 156 | - * @param string $url |
|
| 157 | - * @return string |
|
| 158 | - */ |
|
| 152 | + /** |
|
| 153 | + * Filters a URL: removes control characters and the |
|
| 154 | + * like to have a clean URL to work with. |
|
| 155 | + * |
|
| 156 | + * @param string $url |
|
| 157 | + * @return string |
|
| 158 | + */ |
|
| 159 | 159 | public static function filterURL(string $url) : string |
| 160 | 160 | { |
| 161 | 161 | return URIFilter::filter($url); |
@@ -185,12 +185,12 @@ discard block |
||
| 185 | 185 | return $this->info['type'] === self::TYPE_PHONE; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - /** |
|
| 189 | - * Whether the URL is a regular URL, not one of the |
|
| 190 | - * other types like a phone number or email address. |
|
| 191 | - * |
|
| 192 | - * @return bool |
|
| 193 | - */ |
|
| 188 | + /** |
|
| 189 | + * Whether the URL is a regular URL, not one of the |
|
| 190 | + * other types like a phone number or email address. |
|
| 191 | + * |
|
| 192 | + * @return bool |
|
| 193 | + */ |
|
| 194 | 194 | public function isURL() : bool |
| 195 | 195 | { |
| 196 | 196 | $host = $this->getHost(); |
@@ -202,20 +202,20 @@ discard block |
||
| 202 | 202 | return $this->parser->isValid(); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - /** |
|
| 206 | - * Retrieves the host name, or an empty string if none is present. |
|
| 207 | - * |
|
| 208 | - * @return string |
|
| 209 | - */ |
|
| 205 | + /** |
|
| 206 | + * Retrieves the host name, or an empty string if none is present. |
|
| 207 | + * |
|
| 208 | + * @return string |
|
| 209 | + */ |
|
| 210 | 210 | public function getHost() : string |
| 211 | 211 | { |
| 212 | 212 | return $this->getInfoKey('host'); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Retrieves the path, or an empty string if none is present. |
|
| 217 | - * @return string |
|
| 218 | - */ |
|
| 215 | + /** |
|
| 216 | + * Retrieves the path, or an empty string if none is present. |
|
| 217 | + * @return string |
|
| 218 | + */ |
|
| 219 | 219 | public function getPath() : string |
| 220 | 220 | { |
| 221 | 221 | return $this->getInfoKey('path'); |
@@ -231,10 +231,10 @@ discard block |
||
| 231 | 231 | return $this->getInfoKey('scheme'); |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - /** |
|
| 235 | - * Retrieves the port specified in the URL, or -1 if none is present. |
|
| 236 | - * @return int |
|
| 237 | - */ |
|
| 234 | + /** |
|
| 235 | + * Retrieves the port specified in the URL, or -1 if none is present. |
|
| 236 | + * @return int |
|
| 237 | + */ |
|
| 238 | 238 | public function getPort() : int |
| 239 | 239 | { |
| 240 | 240 | $port = $this->getInfoKey('port'); |
@@ -246,13 +246,13 @@ discard block |
||
| 246 | 246 | return -1; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - /** |
|
| 250 | - * Retrieves the raw query string, or an empty string if none is present. |
|
| 251 | - * |
|
| 252 | - * @return string |
|
| 253 | - * |
|
| 254 | - * @see URLInfo::getParams() |
|
| 255 | - */ |
|
| 249 | + /** |
|
| 250 | + * Retrieves the raw query string, or an empty string if none is present. |
|
| 251 | + * |
|
| 252 | + * @return string |
|
| 253 | + * |
|
| 254 | + * @see URLInfo::getParams() |
|
| 255 | + */ |
|
| 256 | 256 | public function getQuery() : string |
| 257 | 257 | { |
| 258 | 258 | return $this->getInfoKey('query'); |
@@ -268,20 +268,20 @@ discard block |
||
| 268 | 268 | return $this->getInfoKey('pass'); |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - /** |
|
| 272 | - * Whether the URL contains a port number. |
|
| 273 | - * @return bool |
|
| 274 | - */ |
|
| 271 | + /** |
|
| 272 | + * Whether the URL contains a port number. |
|
| 273 | + * @return bool |
|
| 274 | + */ |
|
| 275 | 275 | public function hasPort() : bool |
| 276 | 276 | { |
| 277 | 277 | return $this->getPort() !== -1; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - /** |
|
| 281 | - * Alias for the hasParams() method. |
|
| 282 | - * @return bool |
|
| 283 | - * @see URLInfo::hasParams() |
|
| 284 | - */ |
|
| 280 | + /** |
|
| 281 | + * Alias for the hasParams() method. |
|
| 282 | + * @return bool |
|
| 283 | + * @see URLInfo::hasParams() |
|
| 284 | + */ |
|
| 285 | 285 | public function hasQuery() : bool |
| 286 | 286 | { |
| 287 | 287 | return $this->hasParams(); |
@@ -326,23 +326,23 @@ discard block |
||
| 326 | 326 | return ''; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - /** |
|
| 330 | - * Retrieves a normalized URL: this ensures that all parameters |
|
| 331 | - * in the URL are always in the same order. |
|
| 332 | - * |
|
| 333 | - * @return string |
|
| 334 | - */ |
|
| 329 | + /** |
|
| 330 | + * Retrieves a normalized URL: this ensures that all parameters |
|
| 331 | + * in the URL are always in the same order. |
|
| 332 | + * |
|
| 333 | + * @return string |
|
| 334 | + */ |
|
| 335 | 335 | public function getNormalized() : string |
| 336 | 336 | { |
| 337 | 337 | return $this->normalize(); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - /** |
|
| 341 | - * Like getNormalized(), but if a username and password are present |
|
| 342 | - * in the URL, returns the URL without them. |
|
| 343 | - * |
|
| 344 | - * @return string |
|
| 345 | - */ |
|
| 340 | + /** |
|
| 341 | + * Like getNormalized(), but if a username and password are present |
|
| 342 | + * in the URL, returns the URL without them. |
|
| 343 | + * |
|
| 344 | + * @return string |
|
| 345 | + */ |
|
| 346 | 346 | public function getNormalizedWithoutAuth() : string |
| 347 | 347 | { |
| 348 | 348 | return $this->normalize(false); |
@@ -363,25 +363,25 @@ discard block |
||
| 363 | 363 | return $this->normalizer->normalize(); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - /** |
|
| 367 | - * Creates a hash of the URL, which can be used for comparisons. |
|
| 368 | - * Since any parameters in the URL's query are sorted alphabetically, |
|
| 369 | - * the same links with a different parameter order will have the |
|
| 370 | - * same hash. |
|
| 371 | - * |
|
| 372 | - * @return string |
|
| 373 | - */ |
|
| 366 | + /** |
|
| 367 | + * Creates a hash of the URL, which can be used for comparisons. |
|
| 368 | + * Since any parameters in the URL's query are sorted alphabetically, |
|
| 369 | + * the same links with a different parameter order will have the |
|
| 370 | + * same hash. |
|
| 371 | + * |
|
| 372 | + * @return string |
|
| 373 | + */ |
|
| 374 | 374 | public function getHash() : string |
| 375 | 375 | { |
| 376 | 376 | return ConvertHelper::string2shortHash($this->getNormalized()); |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - /** |
|
| 380 | - * Highlights the URL using HTML tags with specific highlighting |
|
| 381 | - * class names. |
|
| 382 | - * |
|
| 383 | - * @return string Will return an empty string if the URL is not valid. |
|
| 384 | - */ |
|
| 379 | + /** |
|
| 380 | + * Highlights the URL using HTML tags with specific highlighting |
|
| 381 | + * class names. |
|
| 382 | + * |
|
| 383 | + * @return string Will return an empty string if the URL is not valid. |
|
| 384 | + */ |
|
| 385 | 385 | public function getHighlighted() : string |
| 386 | 386 | { |
| 387 | 387 | if(!$this->isValid()) { |
@@ -413,15 +413,15 @@ discard block |
||
| 413 | 413 | return count($params); |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - /** |
|
| 417 | - * Retrieves all parameters specified in the url, |
|
| 418 | - * if any, as an associative array. |
|
| 419 | - * |
|
| 420 | - * NOTE: Ignores parameters that have been added |
|
| 421 | - * to the excluded parameters list. |
|
| 422 | - * |
|
| 423 | - * @return array<string,string> |
|
| 424 | - */ |
|
| 416 | + /** |
|
| 417 | + * Retrieves all parameters specified in the url, |
|
| 418 | + * if any, as an associative array. |
|
| 419 | + * |
|
| 420 | + * NOTE: Ignores parameters that have been added |
|
| 421 | + * to the excluded parameters list. |
|
| 422 | + * |
|
| 423 | + * @return array<string,string> |
|
| 424 | + */ |
|
| 425 | 425 | public function getParams() : array |
| 426 | 426 | { |
| 427 | 427 | if(!$this->paramExclusion || empty($this->excludedParams)) { |
@@ -439,37 +439,37 @@ discard block |
||
| 439 | 439 | return $keep; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - /** |
|
| 443 | - * Retrieves the names of all parameters present in the URL, if any. |
|
| 444 | - * @return string[] |
|
| 445 | - */ |
|
| 442 | + /** |
|
| 443 | + * Retrieves the names of all parameters present in the URL, if any. |
|
| 444 | + * @return string[] |
|
| 445 | + */ |
|
| 446 | 446 | public function getParamNames() : array |
| 447 | 447 | { |
| 448 | 448 | $params = $this->getParams(); |
| 449 | 449 | return array_keys($params); |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - /** |
|
| 453 | - * Retrieves a specific parameter value from the URL. |
|
| 454 | - * |
|
| 455 | - * @param string $name |
|
| 456 | - * @return string The parameter value, or an empty string if it does not exist. |
|
| 457 | - */ |
|
| 452 | + /** |
|
| 453 | + * Retrieves a specific parameter value from the URL. |
|
| 454 | + * |
|
| 455 | + * @param string $name |
|
| 456 | + * @return string The parameter value, or an empty string if it does not exist. |
|
| 457 | + */ |
|
| 458 | 458 | public function getParam(string $name) : string |
| 459 | 459 | { |
| 460 | 460 | return $this->info['params'][$name] ?? ''; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - /** |
|
| 464 | - * Excludes a URL parameter entirely if present: |
|
| 465 | - * the parser will act as if the parameter was not |
|
| 466 | - * even present in the source URL, effectively |
|
| 467 | - * stripping it. |
|
| 468 | - * |
|
| 469 | - * @param string $name |
|
| 470 | - * @param string $reason A human-readable explanation why this is excluded - used when highlighting links. |
|
| 471 | - * @return URLInfo |
|
| 472 | - */ |
|
| 463 | + /** |
|
| 464 | + * Excludes a URL parameter entirely if present: |
|
| 465 | + * the parser will act as if the parameter was not |
|
| 466 | + * even present in the source URL, effectively |
|
| 467 | + * stripping it. |
|
| 468 | + * |
|
| 469 | + * @param string $name |
|
| 470 | + * @param string $reason A human-readable explanation why this is excluded - used when highlighting links. |
|
| 471 | + * @return URLInfo |
|
| 472 | + */ |
|
| 473 | 473 | public function excludeParam(string $name, string $reason='') : URLInfo |
| 474 | 474 | { |
| 475 | 475 | if(!isset($this->excludedParams[$name])) |
@@ -522,14 +522,14 @@ discard block |
||
| 522 | 522 | return self::$typeLabels[$this->getType()]; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | - /** |
|
| 526 | - * Whether excluded parameters should be highlighted in |
|
| 527 | - * a different color in the URL when using the |
|
| 528 | - * {@link URLInfo::getHighlighted()} method. |
|
| 529 | - * |
|
| 530 | - * @param bool $highlight |
|
| 531 | - * @return URLInfo |
|
| 532 | - */ |
|
| 525 | + /** |
|
| 526 | + * Whether excluded parameters should be highlighted in |
|
| 527 | + * a different color in the URL when using the |
|
| 528 | + * {@link URLInfo::getHighlighted()} method. |
|
| 529 | + * |
|
| 530 | + * @param bool $highlight |
|
| 531 | + * @return URLInfo |
|
| 532 | + */ |
|
| 533 | 533 | public function setHighlightExcluded(bool $highlight=true) : URLInfo |
| 534 | 534 | { |
| 535 | 535 | $this->highlightExcluded = $highlight; |
@@ -585,24 +585,24 @@ discard block |
||
| 585 | 585 | return $this; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | - /** |
|
| 589 | - * Whether the parameter exclusion mode is enabled: |
|
| 590 | - * In this case, if any parameters have been added to the |
|
| 591 | - * exclusion list, all relevant methods will exclude these. |
|
| 592 | - * |
|
| 593 | - * @return bool |
|
| 594 | - */ |
|
| 588 | + /** |
|
| 589 | + * Whether the parameter exclusion mode is enabled: |
|
| 590 | + * In this case, if any parameters have been added to the |
|
| 591 | + * exclusion list, all relevant methods will exclude these. |
|
| 592 | + * |
|
| 593 | + * @return bool |
|
| 594 | + */ |
|
| 595 | 595 | public function isParamExclusionEnabled() : bool |
| 596 | 596 | { |
| 597 | 597 | return $this->paramExclusion; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - /** |
|
| 601 | - * Checks whether the link contains any parameters that |
|
| 602 | - * are on the list of excluded parameters. |
|
| 603 | - * |
|
| 604 | - * @return bool |
|
| 605 | - */ |
|
| 600 | + /** |
|
| 601 | + * Checks whether the link contains any parameters that |
|
| 602 | + * are on the list of excluded parameters. |
|
| 603 | + * |
|
| 604 | + * @return bool |
|
| 605 | + */ |
|
| 606 | 606 | public function containsExcludedParams() : bool |
| 607 | 607 | { |
| 608 | 608 | if(empty($this->excludedParams)) { |
@@ -690,26 +690,26 @@ discard block |
||
| 690 | 690 | ->canConnect(); |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - /** |
|
| 694 | - * Creates the connection tester instance that is used |
|
| 695 | - * to check if a URL can be connected to, and which is |
|
| 696 | - * used in the {@see URLInfo::tryConnect()} method. It |
|
| 697 | - * allows more settings to be used. |
|
| 698 | - * |
|
| 699 | - * @return URIConnectionTester |
|
| 700 | - */ |
|
| 693 | + /** |
|
| 694 | + * Creates the connection tester instance that is used |
|
| 695 | + * to check if a URL can be connected to, and which is |
|
| 696 | + * used in the {@see URLInfo::tryConnect()} method. It |
|
| 697 | + * allows more settings to be used. |
|
| 698 | + * |
|
| 699 | + * @return URIConnectionTester |
|
| 700 | + */ |
|
| 701 | 701 | public function createConnectionTester() : URIConnectionTester |
| 702 | 702 | { |
| 703 | 703 | return new URIConnectionTester($this); |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | - /** |
|
| 707 | - * Adds/overwrites a URL parameter. |
|
| 708 | - * |
|
| 709 | - * @param string $name |
|
| 710 | - * @param string $val |
|
| 711 | - * @return URLInfo |
|
| 712 | - */ |
|
| 706 | + /** |
|
| 707 | + * Adds/overwrites a URL parameter. |
|
| 708 | + * |
|
| 709 | + * @param string $name |
|
| 710 | + * @param string $val |
|
| 711 | + * @return URLInfo |
|
| 712 | + */ |
|
| 713 | 713 | public function setParam(string $name, string $val) : URLInfo |
| 714 | 714 | { |
| 715 | 715 | $this->info['params'][$name] = $val; |
@@ -717,13 +717,13 @@ discard block |
||
| 717 | 717 | return $this; |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - /** |
|
| 721 | - * Removes a URL parameter. Has no effect if the |
|
| 722 | - * parameter is not present to begin with. |
|
| 723 | - * |
|
| 724 | - * @param string $param |
|
| 725 | - * @return URLInfo |
|
| 726 | - */ |
|
| 720 | + /** |
|
| 721 | + * Removes a URL parameter. Has no effect if the |
|
| 722 | + * parameter is not present to begin with. |
|
| 723 | + * |
|
| 724 | + * @param string $param |
|
| 725 | + * @return URLInfo |
|
| 726 | + */ |
|
| 727 | 727 | public function removeParam(string $param) : URLInfo |
| 728 | 728 | { |
| 729 | 729 | if(isset($this->info['params'][$param])) |
@@ -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 | } |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | $this->subject = $subject; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function setRemoveDuplicates(bool $remove=true, bool $caseInsensitive=false) : self |
|
| 30 | + public function setRemoveDuplicates(bool $remove = true, bool $caseInsensitive = false) : self |
|
| 31 | 31 | { |
| 32 | 32 | $this->removeDuplicates = $remove; |
| 33 | 33 | $this->duplicatesCaseInsensitive = $caseInsensitive; |
| 34 | 34 | return $this; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function setSorting(bool $sorting=true) : self |
|
| 37 | + public function setSorting(bool $sorting = true) : self |
|
| 38 | 38 | { |
| 39 | 39 | $this->sorting = $sorting; |
| 40 | 40 | return $this; |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $words = $this->filterEmpty($words); |
| 57 | 57 | |
| 58 | - if($this->removeDuplicates) { |
|
| 58 | + if ($this->removeDuplicates) { |
|
| 59 | 59 | $words = $this->filterDuplicates($words); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if($this->sorting) { |
|
| 62 | + if ($this->sorting) { |
|
| 63 | 63 | usort($words, 'strnatcasecmp'); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | private function filterDuplicates(array $words) : array |
| 74 | 74 | { |
| 75 | - if($this->duplicatesCaseInsensitive) { |
|
| 75 | + if ($this->duplicatesCaseInsensitive) { |
|
| 76 | 76 | return $this->filterDuplicatesCaseInsensitive($words); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | return array_intersect_key( |
| 89 | 89 | $array, |
| 90 | - array_unique( array_map( "strtolower", $array ) ) |
|
| 90 | + array_unique(array_map("strtolower", $array)) |
|
| 91 | 91 | ); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | $keep = array(); |
| 101 | 101 | |
| 102 | - foreach($words as $word) |
|
| 102 | + foreach ($words as $word) |
|
| 103 | 103 | { |
| 104 | - if(empty($word)) { |
|
| 104 | + if (empty($word)) { |
|
| 105 | 105 | continue; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if(mb_strlen($word) < $this->minWordLength) { |
|
| 108 | + if (mb_strlen($word) < $this->minWordLength) { |
|
| 109 | 109 | continue; |
| 110 | 110 | } |
| 111 | 111 | |