@@ -20,9 +20,9 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class URLInfo_Highlighter |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var URLInfo |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var URLInfo |
|
| 25 | + */ |
|
| 26 | 26 | protected $info; |
| 27 | 27 | |
| 28 | 28 | public function __construct(URLInfo $info) |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'fragment' |
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | - foreach($parts as $part) |
|
| 80 | + foreach ($parts as $part) |
|
| 81 | 81 | { |
| 82 | 82 | $method = 'render_'.$part; |
| 83 | 83 | $result[] = (string)$this->$method(); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | protected function render_scheme() : string |
| 90 | 90 | { |
| 91 | - if(!$this->info->hasScheme()) { |
|
| 91 | + if (!$this->info->hasScheme()) { |
|
| 92 | 92 | return ''; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | protected function render_username() : string |
| 105 | 105 | { |
| 106 | - if(!$this->info->hasUsername()) { |
|
| 106 | + if (!$this->info->hasUsername()) { |
|
| 107 | 107 | return ''; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | protected function render_host() : string |
| 121 | 121 | { |
| 122 | - if(!$this->info->hasHost()) { |
|
| 122 | + if (!$this->info->hasHost()) { |
|
| 123 | 123 | return ''; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | protected function render_port() : string |
| 133 | 133 | { |
| 134 | - if(!$this->info->hasPort()) { |
|
| 134 | + if (!$this->info->hasPort()) { |
|
| 135 | 135 | return ''; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | protected function render_path() : string |
| 146 | 146 | { |
| 147 | - if(!$this->info->hasPath()) { |
|
| 147 | + if (!$this->info->hasPath()) { |
|
| 148 | 148 | return ''; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -162,19 +162,19 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | $params = $this->info->getParams(); |
| 164 | 164 | |
| 165 | - if(empty($params)) { |
|
| 165 | + if (empty($params)) { |
|
| 166 | 166 | return ''; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $tokens = array(); |
| 170 | 170 | $excluded = array(); |
| 171 | 171 | |
| 172 | - if($this->info->isParamExclusionEnabled()) |
|
| 172 | + if ($this->info->isParamExclusionEnabled()) |
|
| 173 | 173 | { |
| 174 | 174 | $excluded = $this->info->getExcludedParams(); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - foreach($params as $param => $value) |
|
| 177 | + foreach ($params as $param => $value) |
|
| 178 | 178 | { |
| 179 | 179 | $parts = sprintf( |
| 180 | 180 | '<span class="link-param-name">%s</span>'. |
@@ -192,10 +192,10 @@ discard block |
||
| 192 | 192 | $tag = ''; |
| 193 | 193 | |
| 194 | 194 | // is parameter exclusion enabled, and is this an excluded parameter? |
| 195 | - if(isset($excluded[$param])) |
|
| 195 | + if (isset($excluded[$param])) |
|
| 196 | 196 | { |
| 197 | 197 | // display the excluded parameter, but highlight it |
| 198 | - if($this->info->isHighlightExcludeEnabled()) |
|
| 198 | + if ($this->info->isHighlightExcludeEnabled()) |
|
| 199 | 199 | { |
| 200 | 200 | $tooltip = $excluded[$param]; |
| 201 | 201 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | protected function render_fragment() : string |
| 230 | 230 | { |
| 231 | - if(!$this->info->hasFragment()) { |
|
| 231 | + if (!$this->info->hasFragment()) { |
|
| 232 | 232 | return ''; |
| 233 | 233 | } |
| 234 | 234 | |
@@ -204,13 +204,11 @@ |
||
| 204 | 204 | $tooltip, |
| 205 | 205 | $parts |
| 206 | 206 | ); |
| 207 | - } |
|
| 208 | - else |
|
| 207 | + } else |
|
| 209 | 208 | { |
| 210 | 209 | continue; |
| 211 | 210 | } |
| 212 | - } |
|
| 213 | - else |
|
| 211 | + } else |
|
| 214 | 212 | { |
| 215 | 213 | $tag = sprintf( |
| 216 | 214 | '<span class="link-param">%s</span>', |
@@ -37,42 +37,42 @@ discard block |
||
| 37 | 37 | const TYPE_PHONE = 'phone'; |
| 38 | 38 | const TYPE_URL = 'url'; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * The original URL that was passed to the constructor. |
|
| 42 | - * @var string |
|
| 43 | - */ |
|
| 40 | + /** |
|
| 41 | + * The original URL that was passed to the constructor. |
|
| 42 | + * @var string |
|
| 43 | + */ |
|
| 44 | 44 | protected $rawURL; |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var array |
|
| 48 | - */ |
|
| 46 | + /** |
|
| 47 | + * @var array |
|
| 48 | + */ |
|
| 49 | 49 | protected $info; |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var string[] |
|
| 53 | - */ |
|
| 51 | + /** |
|
| 52 | + * @var string[] |
|
| 53 | + */ |
|
| 54 | 54 | protected $excludedParams = array(); |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var bool |
|
| 58 | - * @see URLInfo::setParamExclusion() |
|
| 59 | - */ |
|
| 56 | + /** |
|
| 57 | + * @var bool |
|
| 58 | + * @see URLInfo::setParamExclusion() |
|
| 59 | + */ |
|
| 60 | 60 | protected $paramExclusion = false; |
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @var array |
|
| 64 | - * @see URLInfo::getTypeLabel() |
|
| 65 | - */ |
|
| 62 | + /** |
|
| 63 | + * @var array |
|
| 64 | + * @see URLInfo::getTypeLabel() |
|
| 65 | + */ |
|
| 66 | 66 | protected static $typeLabels; |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @var bool |
|
| 70 | - */ |
|
| 68 | + /** |
|
| 69 | + * @var bool |
|
| 70 | + */ |
|
| 71 | 71 | protected $highlightExcluded = false; |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @var array |
|
| 75 | - */ |
|
| 73 | + /** |
|
| 74 | + * @var array |
|
| 75 | + */ |
|
| 76 | 76 | protected $infoKeys = array( |
| 77 | 77 | 'scheme', |
| 78 | 78 | 'host', |
@@ -84,14 +84,14 @@ discard block |
||
| 84 | 84 | 'fragment' |
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * @var string |
|
| 89 | - */ |
|
| 87 | + /** |
|
| 88 | + * @var string |
|
| 89 | + */ |
|
| 90 | 90 | protected $url; |
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * @var URLInfo_Parser |
|
| 94 | - */ |
|
| 92 | + /** |
|
| 93 | + * @var URLInfo_Parser |
|
| 94 | + */ |
|
| 95 | 95 | protected $parser; |
| 96 | 96 | |
| 97 | 97 | public function __construct(string $url) |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | $this->info = $this->parser->getInfo(); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Filters an URL: removes control characters and the |
|
| 108 | - * like to have a clean URL to work with. |
|
| 109 | - * |
|
| 110 | - * @param string $url |
|
| 111 | - * @return string |
|
| 112 | - */ |
|
| 106 | + /** |
|
| 107 | + * Filters an URL: removes control characters and the |
|
| 108 | + * like to have a clean URL to work with. |
|
| 109 | + * |
|
| 110 | + * @param string $url |
|
| 111 | + * @return string |
|
| 112 | + */ |
|
| 113 | 113 | public static function filterURL(string $url) |
| 114 | 114 | { |
| 115 | 115 | return URLInfo_Filter::filter($url); |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | return $this->info['type'] === self::TYPE_PHONE; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - /** |
|
| 147 | - * Whether the URL is a regular URL, not one of the |
|
| 148 | - * other types like a phone number or email address. |
|
| 149 | - * |
|
| 150 | - * @return bool |
|
| 151 | - */ |
|
| 146 | + /** |
|
| 147 | + * Whether the URL is a regular URL, not one of the |
|
| 148 | + * other types like a phone number or email address. |
|
| 149 | + * |
|
| 150 | + * @return bool |
|
| 151 | + */ |
|
| 152 | 152 | public function isURL() : bool |
| 153 | 153 | { |
| 154 | 154 | $host = $this->getHost(); |
@@ -160,20 +160,20 @@ discard block |
||
| 160 | 160 | return $this->parser->isValid(); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * Retrieves the host name, or an empty string if none is present. |
|
| 165 | - * |
|
| 166 | - * @return string |
|
| 167 | - */ |
|
| 163 | + /** |
|
| 164 | + * Retrieves the host name, or an empty string if none is present. |
|
| 165 | + * |
|
| 166 | + * @return string |
|
| 167 | + */ |
|
| 168 | 168 | public function getHost() : string |
| 169 | 169 | { |
| 170 | 170 | return $this->getInfoKey('host'); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - /** |
|
| 174 | - * Retrieves the path, or an empty string if none is present. |
|
| 175 | - * @return string |
|
| 176 | - */ |
|
| 173 | + /** |
|
| 174 | + * Retrieves the path, or an empty string if none is present. |
|
| 175 | + * @return string |
|
| 176 | + */ |
|
| 177 | 177 | public function getPath() : string |
| 178 | 178 | { |
| 179 | 179 | return $this->getInfoKey('path'); |
@@ -189,10 +189,10 @@ discard block |
||
| 189 | 189 | return $this->getInfoKey('scheme'); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
| 194 | - * @return int |
|
| 195 | - */ |
|
| 192 | + /** |
|
| 193 | + * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
| 194 | + * @return int |
|
| 195 | + */ |
|
| 196 | 196 | public function getPort() : int |
| 197 | 197 | { |
| 198 | 198 | $port = $this->getInfoKey('port'); |
@@ -203,13 +203,13 @@ discard block |
||
| 203 | 203 | return -1; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - /** |
|
| 207 | - * Retrieves the raw query string, or an empty string if none is present. |
|
| 208 | - * |
|
| 209 | - * @return string |
|
| 210 | - * |
|
| 211 | - * @see URLInfo::getParams() |
|
| 212 | - */ |
|
| 206 | + /** |
|
| 207 | + * Retrieves the raw query string, or an empty string if none is present. |
|
| 208 | + * |
|
| 209 | + * @return string |
|
| 210 | + * |
|
| 211 | + * @see URLInfo::getParams() |
|
| 212 | + */ |
|
| 213 | 213 | public function getQuery() : string |
| 214 | 214 | { |
| 215 | 215 | return $this->getInfoKey('query'); |
@@ -225,20 +225,20 @@ discard block |
||
| 225 | 225 | return $this->getInfoKey('pass'); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - /** |
|
| 229 | - * Whether the URL contains a port number. |
|
| 230 | - * @return bool |
|
| 231 | - */ |
|
| 228 | + /** |
|
| 229 | + * Whether the URL contains a port number. |
|
| 230 | + * @return bool |
|
| 231 | + */ |
|
| 232 | 232 | public function hasPort() : bool |
| 233 | 233 | { |
| 234 | 234 | return $this->getPort() !== -1; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * Alias for the hasParams() method. |
|
| 239 | - * @return bool |
|
| 240 | - * @see URLInfo::hasParams() |
|
| 241 | - */ |
|
| 237 | + /** |
|
| 238 | + * Alias for the hasParams() method. |
|
| 239 | + * @return bool |
|
| 240 | + * @see URLInfo::hasParams() |
|
| 241 | + */ |
|
| 242 | 242 | public function hasQuery() : bool |
| 243 | 243 | { |
| 244 | 244 | return $this->hasParams(); |
@@ -319,25 +319,25 @@ discard block |
||
| 319 | 319 | return $normalized; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - /** |
|
| 323 | - * Creates a hash of the URL, which can be used for comparisons. |
|
| 324 | - * Since any parameters in the URL's query are sorted alphabetically, |
|
| 325 | - * the same links with a different parameter order will have the |
|
| 326 | - * same hash. |
|
| 327 | - * |
|
| 328 | - * @return string |
|
| 329 | - */ |
|
| 322 | + /** |
|
| 323 | + * Creates a hash of the URL, which can be used for comparisons. |
|
| 324 | + * Since any parameters in the URL's query are sorted alphabetically, |
|
| 325 | + * the same links with a different parameter order will have the |
|
| 326 | + * same hash. |
|
| 327 | + * |
|
| 328 | + * @return string |
|
| 329 | + */ |
|
| 330 | 330 | public function getHash() |
| 331 | 331 | { |
| 332 | 332 | return \AppUtils\ConvertHelper::string2shortHash($this->getNormalized()); |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - /** |
|
| 336 | - * Highlights the URL using HTML tags with specific highlighting |
|
| 337 | - * class names. |
|
| 338 | - * |
|
| 339 | - * @return string Will return an empty string if the URL is not valid. |
|
| 340 | - */ |
|
| 335 | + /** |
|
| 336 | + * Highlights the URL using HTML tags with specific highlighting |
|
| 337 | + * class names. |
|
| 338 | + * |
|
| 339 | + * @return string Will return an empty string if the URL is not valid. |
|
| 340 | + */ |
|
| 341 | 341 | public function getHighlighted() : string |
| 342 | 342 | { |
| 343 | 343 | if(!$this->isValid()) { |
@@ -371,15 +371,15 @@ discard block |
||
| 371 | 371 | return count($params); |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - /** |
|
| 375 | - * Retrieves all parameters specified in the url, |
|
| 376 | - * if any, as an associative array. |
|
| 377 | - * |
|
| 378 | - * NOTE: Ignores parameters that have been added |
|
| 379 | - * to the excluded parameters list. |
|
| 380 | - * |
|
| 381 | - * @return array |
|
| 382 | - */ |
|
| 374 | + /** |
|
| 375 | + * Retrieves all parameters specified in the url, |
|
| 376 | + * if any, as an associative array. |
|
| 377 | + * |
|
| 378 | + * NOTE: Ignores parameters that have been added |
|
| 379 | + * to the excluded parameters list. |
|
| 380 | + * |
|
| 381 | + * @return array |
|
| 382 | + */ |
|
| 383 | 383 | public function getParams() : array |
| 384 | 384 | { |
| 385 | 385 | if(!$this->paramExclusion || empty($this->excludedParams)) { |
@@ -396,22 +396,22 @@ discard block |
||
| 396 | 396 | return $keep; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - /** |
|
| 400 | - * Retrieves the names of all parameters present in the URL, if any. |
|
| 401 | - * @return string[] |
|
| 402 | - */ |
|
| 399 | + /** |
|
| 400 | + * Retrieves the names of all parameters present in the URL, if any. |
|
| 401 | + * @return string[] |
|
| 402 | + */ |
|
| 403 | 403 | public function getParamNames() : array |
| 404 | 404 | { |
| 405 | 405 | $params = $this->getParams(); |
| 406 | 406 | return array_keys($params); |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - /** |
|
| 410 | - * Retrieves a specific parameter value from the URL. |
|
| 411 | - * |
|
| 412 | - * @param string $name |
|
| 413 | - * @return string The parameter value, or an empty string if it does not exist. |
|
| 414 | - */ |
|
| 409 | + /** |
|
| 410 | + * Retrieves a specific parameter value from the URL. |
|
| 411 | + * |
|
| 412 | + * @param string $name |
|
| 413 | + * @return string The parameter value, or an empty string if it does not exist. |
|
| 414 | + */ |
|
| 415 | 415 | public function getParam(string $name) : string |
| 416 | 416 | { |
| 417 | 417 | if(isset($this->info['params'][$name])) { |
@@ -421,16 +421,16 @@ discard block |
||
| 421 | 421 | return ''; |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - /** |
|
| 425 | - * Excludes an URL parameter entirely if present: |
|
| 426 | - * the parser will act as if the parameter was not |
|
| 427 | - * even present in the source URL, effectively |
|
| 428 | - * stripping it. |
|
| 429 | - * |
|
| 430 | - * @param string $name |
|
| 431 | - * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
| 432 | - * @return URLInfo |
|
| 433 | - */ |
|
| 424 | + /** |
|
| 425 | + * Excludes an URL parameter entirely if present: |
|
| 426 | + * the parser will act as if the parameter was not |
|
| 427 | + * even present in the source URL, effectively |
|
| 428 | + * stripping it. |
|
| 429 | + * |
|
| 430 | + * @param string $name |
|
| 431 | + * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
| 432 | + * @return URLInfo |
|
| 433 | + */ |
|
| 434 | 434 | public function excludeParam(string $name, string $reason) : URLInfo |
| 435 | 435 | { |
| 436 | 436 | if(!isset($this->excludedParams[$name])) |
@@ -483,25 +483,25 @@ discard block |
||
| 483 | 483 | return self::$typeLabels[$this->getType()]; |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | - /** |
|
| 487 | - * Whether excluded parameters should be highlighted in |
|
| 488 | - * a different color in the URL when using the |
|
| 489 | - * {@link URLInfo::getHighlighted()} method. |
|
| 490 | - * |
|
| 491 | - * @param bool $highlight |
|
| 492 | - * @return URLInfo |
|
| 493 | - */ |
|
| 486 | + /** |
|
| 487 | + * Whether excluded parameters should be highlighted in |
|
| 488 | + * a different color in the URL when using the |
|
| 489 | + * {@link URLInfo::getHighlighted()} method. |
|
| 490 | + * |
|
| 491 | + * @param bool $highlight |
|
| 492 | + * @return URLInfo |
|
| 493 | + */ |
|
| 494 | 494 | public function setHighlightExcluded(bool $highlight=true) : URLInfo |
| 495 | 495 | { |
| 496 | 496 | $this->highlightExcluded = $highlight; |
| 497 | 497 | return $this; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - /** |
|
| 501 | - * Returns an array with all relevant URL information. |
|
| 502 | - * |
|
| 503 | - * @return array |
|
| 504 | - */ |
|
| 500 | + /** |
|
| 501 | + * Returns an array with all relevant URL information. |
|
| 502 | + * |
|
| 503 | + * @return array |
|
| 504 | + */ |
|
| 505 | 505 | public function toArray() : array |
| 506 | 506 | { |
| 507 | 507 | return array( |
@@ -545,24 +545,24 @@ discard block |
||
| 545 | 545 | return $this; |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - /** |
|
| 549 | - * Whether the parameter exclusion mode is enabled: |
|
| 550 | - * In this case, if any parameters have been added to the |
|
| 551 | - * exclusion list, all relevant methods will exclude these. |
|
| 552 | - * |
|
| 553 | - * @return bool |
|
| 554 | - */ |
|
| 548 | + /** |
|
| 549 | + * Whether the parameter exclusion mode is enabled: |
|
| 550 | + * In this case, if any parameters have been added to the |
|
| 551 | + * exclusion list, all relevant methods will exclude these. |
|
| 552 | + * |
|
| 553 | + * @return bool |
|
| 554 | + */ |
|
| 555 | 555 | public function isParamExclusionEnabled() : bool |
| 556 | 556 | { |
| 557 | 557 | return $this->paramExclusion; |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - /** |
|
| 561 | - * Checks whether the link contains any parameters that |
|
| 562 | - * are on the list of excluded parameters. |
|
| 563 | - * |
|
| 564 | - * @return bool |
|
| 565 | - */ |
|
| 560 | + /** |
|
| 561 | + * Checks whether the link contains any parameters that |
|
| 562 | + * are on the list of excluded parameters. |
|
| 563 | + * |
|
| 564 | + * @return bool |
|
| 565 | + */ |
|
| 566 | 566 | public function containsExcludedParams() : bool |
| 567 | 567 | { |
| 568 | 568 | if(empty($this->excludedParams)) { |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function isSecure() : bool |
| 123 | 123 | { |
| 124 | - if(isset($this->info['scheme']) && $this->info['scheme'] === 'https') { |
|
| 124 | + if (isset($this->info['scheme']) && $this->info['scheme'] === 'https') { |
|
| 125 | 125 | return true; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | public function getPort() : int |
| 197 | 197 | { |
| 198 | 198 | $port = $this->getInfoKey('port'); |
| 199 | - if(!empty($port)) { |
|
| 199 | + if (!empty($port)) { |
|
| 200 | 200 | return (int)$port; |
| 201 | 201 | } |
| 202 | 202 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | protected function getInfoKey(string $name) : string |
| 278 | 278 | { |
| 279 | - if(isset($this->info[$name])) { |
|
| 279 | + if (isset($this->info[$name])) { |
|
| 280 | 280 | return (string)$this->info[$name]; |
| 281 | 281 | } |
| 282 | 282 | |
@@ -285,34 +285,34 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | public function getNormalized() : string |
| 287 | 287 | { |
| 288 | - if(!$this->isValid()) { |
|
| 288 | + if (!$this->isValid()) { |
|
| 289 | 289 | return ''; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if($this->isAnchor()) |
|
| 292 | + if ($this->isAnchor()) |
|
| 293 | 293 | { |
| 294 | 294 | return '#'.$this->getFragment(); |
| 295 | 295 | } |
| 296 | - else if($this->isPhoneNumber()) |
|
| 296 | + else if ($this->isPhoneNumber()) |
|
| 297 | 297 | { |
| 298 | 298 | return 'tel://'.$this->getHost(); |
| 299 | 299 | } |
| 300 | - else if($this->isEmail()) |
|
| 300 | + else if ($this->isEmail()) |
|
| 301 | 301 | { |
| 302 | 302 | return 'mailto:'.$this->getPath(); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | $normalized = $this->info['scheme'].'://'.$this->info['host']; |
| 306 | - if(isset($this->info['path'])) { |
|
| 306 | + if (isset($this->info['path'])) { |
|
| 307 | 307 | $normalized .= $this->info['path']; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | $params = $this->getParams(); |
| 311 | - if(!empty($params)) { |
|
| 311 | + if (!empty($params)) { |
|
| 312 | 312 | $normalized .= '?'.http_build_query($params); |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - if(isset($this->info['fragment'])) { |
|
| 315 | + if (isset($this->info['fragment'])) { |
|
| 316 | 316 | $normalized .= '#'.$this->info['fragment']; |
| 317 | 317 | } |
| 318 | 318 | |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | public function getHighlighted() : string |
| 342 | 342 | { |
| 343 | - if(!$this->isValid()) { |
|
| 343 | + if (!$this->isValid()) { |
|
| 344 | 344 | return ''; |
| 345 | 345 | } |
| 346 | 346 | |
@@ -382,13 +382,13 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | public function getParams() : array |
| 384 | 384 | { |
| 385 | - if(!$this->paramExclusion || empty($this->excludedParams)) { |
|
| 385 | + if (!$this->paramExclusion || empty($this->excludedParams)) { |
|
| 386 | 386 | return $this->info['params']; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | $keep = array(); |
| 390 | - foreach($this->info['params'] as $name => $value) { |
|
| 391 | - if(!isset($this->excludedParams[$name])) { |
|
| 390 | + foreach ($this->info['params'] as $name => $value) { |
|
| 391 | + if (!isset($this->excludedParams[$name])) { |
|
| 392 | 392 | $keep[$name] = $value; |
| 393 | 393 | } |
| 394 | 394 | } |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | */ |
| 415 | 415 | public function getParam(string $name) : string |
| 416 | 416 | { |
| 417 | - if(isset($this->info['params'][$name])) { |
|
| 417 | + if (isset($this->info['params'][$name])) { |
|
| 418 | 418 | return $this->info['params'][$name]; |
| 419 | 419 | } |
| 420 | 420 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | */ |
| 434 | 434 | public function excludeParam(string $name, string $reason) : URLInfo |
| 435 | 435 | { |
| 436 | - if(!isset($this->excludedParams[$name])) |
|
| 436 | + if (!isset($this->excludedParams[$name])) |
|
| 437 | 437 | { |
| 438 | 438 | $this->excludedParams[$name] = $reason; |
| 439 | 439 | $this->setParamExclusion(); |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | |
| 460 | 460 | public function getTypeLabel() : string |
| 461 | 461 | { |
| 462 | - if(!isset(self::$typeLabels)) |
|
| 462 | + if (!isset(self::$typeLabels)) |
|
| 463 | 463 | { |
| 464 | 464 | self::$typeLabels = array( |
| 465 | 465 | self::TYPE_EMAIL => t('Email'), |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | |
| 472 | 472 | $type = $this->getType(); |
| 473 | 473 | |
| 474 | - if(!isset(self::$typeLabels[$type])) |
|
| 474 | + if (!isset(self::$typeLabels[$type])) |
|
| 475 | 475 | { |
| 476 | 476 | throw new BaseException( |
| 477 | 477 | sprintf('Unknown URL type label for type [%s].', $type), |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * @param bool $highlight |
| 492 | 492 | * @return URLInfo |
| 493 | 493 | */ |
| 494 | - public function setHighlightExcluded(bool $highlight=true) : URLInfo |
|
| 494 | + public function setHighlightExcluded(bool $highlight = true) : URLInfo |
|
| 495 | 495 | { |
| 496 | 496 | $this->highlightExcluded = $highlight; |
| 497 | 497 | return $this; |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | * @see URLInfo::isParamExclusionEnabled() |
| 540 | 540 | * @see URLInfo::setHighlightExcluded() |
| 541 | 541 | */ |
| 542 | - public function setParamExclusion(bool $enabled=true) : URLInfo |
|
| 542 | + public function setParamExclusion(bool $enabled = true) : URLInfo |
|
| 543 | 543 | { |
| 544 | 544 | $this->paramExclusion = $enabled; |
| 545 | 545 | return $this; |
@@ -565,13 +565,13 @@ discard block |
||
| 565 | 565 | */ |
| 566 | 566 | public function containsExcludedParams() : bool |
| 567 | 567 | { |
| 568 | - if(empty($this->excludedParams)) { |
|
| 568 | + if (empty($this->excludedParams)) { |
|
| 569 | 569 | return false; |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | $names = array_keys($this->info['params']); |
| 573 | - foreach($names as $name) { |
|
| 574 | - if(isset($this->excludedParams[$name])) { |
|
| 573 | + foreach ($names as $name) { |
|
| 574 | + if (isset($this->excludedParams[$name])) { |
|
| 575 | 575 | return true; |
| 576 | 576 | } |
| 577 | 577 | } |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | |
| 588 | 588 | public function offsetSet($offset, $value) |
| 589 | 589 | { |
| 590 | - if(in_array($offset, $this->infoKeys)) { |
|
| 590 | + if (in_array($offset, $this->infoKeys)) { |
|
| 591 | 591 | $this->info[$offset] = $value; |
| 592 | 592 | } |
| 593 | 593 | } |
@@ -604,11 +604,11 @@ discard block |
||
| 604 | 604 | |
| 605 | 605 | public function offsetGet($offset) |
| 606 | 606 | { |
| 607 | - if($offset === 'port') { |
|
| 607 | + if ($offset === 'port') { |
|
| 608 | 608 | return $this->getPort(); |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - if(in_array($offset, $this->infoKeys)) { |
|
| 611 | + if (in_array($offset, $this->infoKeys)) { |
|
| 612 | 612 | return $this->getInfoKey($offset); |
| 613 | 613 | } |
| 614 | 614 | |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | { |
| 620 | 620 | $cssFolder = realpath(__DIR__.'/../css'); |
| 621 | 621 | |
| 622 | - if($cssFolder === false) { |
|
| 622 | + if ($cssFolder === false) { |
|
| 623 | 623 | throw new BaseException( |
| 624 | 624 | 'Cannot find package CSS folder.', |
| 625 | 625 | null, |
@@ -292,12 +292,10 @@ |
||
| 292 | 292 | if($this->isAnchor()) |
| 293 | 293 | { |
| 294 | 294 | return '#'.$this->getFragment(); |
| 295 | - } |
|
| 296 | - else if($this->isPhoneNumber()) |
|
| 295 | + } else if($this->isPhoneNumber()) |
|
| 297 | 296 | { |
| 298 | 297 | return 'tel://'.$this->getHost(); |
| 299 | - } |
|
| 300 | - else if($this->isEmail()) |
|
| 298 | + } else if($this->isEmail()) |
|
| 301 | 299 | { |
| 302 | 300 | return 'mailto:'.$this->getPath(); |
| 303 | 301 | } |