@@ -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, |
@@ -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 | } |
@@ -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) |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | return $this->parser; |
131 | 131 | } |
132 | 132 | |
133 | - /** |
|
134 | - * Whether to URL encode any non-encoded UTF8 characters in the URL. |
|
135 | - * Default is to leave them as-is for better readability, since |
|
136 | - * browsers handle this well. |
|
137 | - * |
|
138 | - * @param bool $enabled |
|
139 | - * @return URLInfo |
|
140 | - */ |
|
133 | + /** |
|
134 | + * Whether to URL encode any non-encoded UTF8 characters in the URL. |
|
135 | + * Default is to leave them as-is for better readability, since |
|
136 | + * browsers handle this well. |
|
137 | + * |
|
138 | + * @param bool $enabled |
|
139 | + * @return URLInfo |
|
140 | + */ |
|
141 | 141 | public function setUTFEncoding(bool $enabled=true) : URLInfo |
142 | 142 | { |
143 | 143 | if($this->encodeUTFChars !== $enabled) |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | return $this->encodeUTFChars; |
155 | 155 | } |
156 | 156 | |
157 | - /** |
|
158 | - * Filters a URL: removes control characters and the |
|
159 | - * like to have a clean URL to work with. |
|
160 | - * |
|
161 | - * @param string $url |
|
162 | - * @return string |
|
163 | - */ |
|
157 | + /** |
|
158 | + * Filters a URL: removes control characters and the |
|
159 | + * like to have a clean URL to work with. |
|
160 | + * |
|
161 | + * @param string $url |
|
162 | + * @return string |
|
163 | + */ |
|
164 | 164 | public static function filterURL(string $url) : string |
165 | 165 | { |
166 | 166 | return URIFilter::filter($url); |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | return $this->info['type'] === self::TYPE_PHONE; |
191 | 191 | } |
192 | 192 | |
193 | - /** |
|
194 | - * Whether the URL is a regular URL, not one of the |
|
195 | - * other types like a phone number or email address. |
|
196 | - * |
|
197 | - * @return bool |
|
198 | - */ |
|
193 | + /** |
|
194 | + * Whether the URL is a regular URL, not one of the |
|
195 | + * other types like a phone number or email address. |
|
196 | + * |
|
197 | + * @return bool |
|
198 | + */ |
|
199 | 199 | public function isURL() : bool |
200 | 200 | { |
201 | 201 | $host = $this->getHost(); |
@@ -207,20 +207,20 @@ discard block |
||
207 | 207 | return $this->parser->isValid(); |
208 | 208 | } |
209 | 209 | |
210 | - /** |
|
211 | - * Retrieves the host name, or an empty string if none is present. |
|
212 | - * |
|
213 | - * @return string |
|
214 | - */ |
|
210 | + /** |
|
211 | + * Retrieves the host name, or an empty string if none is present. |
|
212 | + * |
|
213 | + * @return string |
|
214 | + */ |
|
215 | 215 | public function getHost() : string |
216 | 216 | { |
217 | 217 | return $this->getInfoKey('host'); |
218 | 218 | } |
219 | 219 | |
220 | - /** |
|
221 | - * Retrieves the path, or an empty string if none is present. |
|
222 | - * @return string |
|
223 | - */ |
|
220 | + /** |
|
221 | + * Retrieves the path, or an empty string if none is present. |
|
222 | + * @return string |
|
223 | + */ |
|
224 | 224 | public function getPath() : string |
225 | 225 | { |
226 | 226 | return $this->getInfoKey('path'); |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | return $this->getInfoKey('scheme'); |
237 | 237 | } |
238 | 238 | |
239 | - /** |
|
240 | - * Retrieves the port specified in the URL, or -1 if none is present. |
|
241 | - * @return int |
|
242 | - */ |
|
239 | + /** |
|
240 | + * Retrieves the port specified in the URL, or -1 if none is present. |
|
241 | + * @return int |
|
242 | + */ |
|
243 | 243 | public function getPort() : int |
244 | 244 | { |
245 | 245 | $port = $this->getInfoKey('port'); |
@@ -251,13 +251,13 @@ discard block |
||
251 | 251 | return -1; |
252 | 252 | } |
253 | 253 | |
254 | - /** |
|
255 | - * Retrieves the raw query string, or an empty string if none is present. |
|
256 | - * |
|
257 | - * @return string |
|
258 | - * |
|
259 | - * @see URLInfo::getParams() |
|
260 | - */ |
|
254 | + /** |
|
255 | + * Retrieves the raw query string, or an empty string if none is present. |
|
256 | + * |
|
257 | + * @return string |
|
258 | + * |
|
259 | + * @see URLInfo::getParams() |
|
260 | + */ |
|
261 | 261 | public function getQuery() : string |
262 | 262 | { |
263 | 263 | return $this->getInfoKey('query'); |
@@ -273,20 +273,20 @@ discard block |
||
273 | 273 | return $this->getInfoKey('pass'); |
274 | 274 | } |
275 | 275 | |
276 | - /** |
|
277 | - * Whether the URL contains a port number. |
|
278 | - * @return bool |
|
279 | - */ |
|
276 | + /** |
|
277 | + * Whether the URL contains a port number. |
|
278 | + * @return bool |
|
279 | + */ |
|
280 | 280 | public function hasPort() : bool |
281 | 281 | { |
282 | 282 | return $this->getPort() !== -1; |
283 | 283 | } |
284 | 284 | |
285 | - /** |
|
286 | - * Alias for the hasParams() method. |
|
287 | - * @return bool |
|
288 | - * @see URLInfo::hasParams() |
|
289 | - */ |
|
285 | + /** |
|
286 | + * Alias for the hasParams() method. |
|
287 | + * @return bool |
|
288 | + * @see URLInfo::hasParams() |
|
289 | + */ |
|
290 | 290 | public function hasQuery() : bool |
291 | 291 | { |
292 | 292 | return $this->hasParams(); |
@@ -331,23 +331,23 @@ discard block |
||
331 | 331 | return ''; |
332 | 332 | } |
333 | 333 | |
334 | - /** |
|
335 | - * Retrieves a normalized URL: this ensures that all parameters |
|
336 | - * in the URL are always in the same order. |
|
337 | - * |
|
338 | - * @return string |
|
339 | - */ |
|
334 | + /** |
|
335 | + * Retrieves a normalized URL: this ensures that all parameters |
|
336 | + * in the URL are always in the same order. |
|
337 | + * |
|
338 | + * @return string |
|
339 | + */ |
|
340 | 340 | public function getNormalized() : string |
341 | 341 | { |
342 | 342 | return $this->normalize(); |
343 | 343 | } |
344 | 344 | |
345 | - /** |
|
346 | - * Like getNormalized(), but if a username and password are present |
|
347 | - * in the URL, returns the URL without them. |
|
348 | - * |
|
349 | - * @return string |
|
350 | - */ |
|
345 | + /** |
|
346 | + * Like getNormalized(), but if a username and password are present |
|
347 | + * in the URL, returns the URL without them. |
|
348 | + * |
|
349 | + * @return string |
|
350 | + */ |
|
351 | 351 | public function getNormalizedWithoutAuth() : string |
352 | 352 | { |
353 | 353 | return $this->normalize(false); |
@@ -368,25 +368,25 @@ discard block |
||
368 | 368 | return $this->normalizer->normalize(); |
369 | 369 | } |
370 | 370 | |
371 | - /** |
|
372 | - * Creates a hash of the URL, which can be used for comparisons. |
|
373 | - * Since any parameters in the URL's query are sorted alphabetically, |
|
374 | - * the same links with a different parameter order will have the |
|
375 | - * same hash. |
|
376 | - * |
|
377 | - * @return string |
|
378 | - */ |
|
371 | + /** |
|
372 | + * Creates a hash of the URL, which can be used for comparisons. |
|
373 | + * Since any parameters in the URL's query are sorted alphabetically, |
|
374 | + * the same links with a different parameter order will have the |
|
375 | + * same hash. |
|
376 | + * |
|
377 | + * @return string |
|
378 | + */ |
|
379 | 379 | public function getHash() : string |
380 | 380 | { |
381 | 381 | return ConvertHelper::string2shortHash($this->getNormalized()); |
382 | 382 | } |
383 | 383 | |
384 | - /** |
|
385 | - * Highlights the URL using HTML tags with specific highlighting |
|
386 | - * class names. |
|
387 | - * |
|
388 | - * @return string Will return an empty string if the URL is not valid. |
|
389 | - */ |
|
384 | + /** |
|
385 | + * Highlights the URL using HTML tags with specific highlighting |
|
386 | + * class names. |
|
387 | + * |
|
388 | + * @return string Will return an empty string if the URL is not valid. |
|
389 | + */ |
|
390 | 390 | public function getHighlighted() : string |
391 | 391 | { |
392 | 392 | if(!$this->isValid()) { |
@@ -418,15 +418,15 @@ discard block |
||
418 | 418 | return count($params); |
419 | 419 | } |
420 | 420 | |
421 | - /** |
|
422 | - * Retrieves all parameters specified in the url, |
|
423 | - * if any, as an associative array. |
|
424 | - * |
|
425 | - * NOTE: Ignores parameters that have been added |
|
426 | - * to the excluded parameters list. |
|
427 | - * |
|
428 | - * @return array<string,string> |
|
429 | - */ |
|
421 | + /** |
|
422 | + * Retrieves all parameters specified in the url, |
|
423 | + * if any, as an associative array. |
|
424 | + * |
|
425 | + * NOTE: Ignores parameters that have been added |
|
426 | + * to the excluded parameters list. |
|
427 | + * |
|
428 | + * @return array<string,string> |
|
429 | + */ |
|
430 | 430 | public function getParams() : array |
431 | 431 | { |
432 | 432 | if(!$this->paramExclusion || empty($this->excludedParams)) { |
@@ -444,37 +444,37 @@ discard block |
||
444 | 444 | return $keep; |
445 | 445 | } |
446 | 446 | |
447 | - /** |
|
448 | - * Retrieves the names of all parameters present in the URL, if any. |
|
449 | - * @return string[] |
|
450 | - */ |
|
447 | + /** |
|
448 | + * Retrieves the names of all parameters present in the URL, if any. |
|
449 | + * @return string[] |
|
450 | + */ |
|
451 | 451 | public function getParamNames() : array |
452 | 452 | { |
453 | 453 | $params = $this->getParams(); |
454 | 454 | return array_keys($params); |
455 | 455 | } |
456 | 456 | |
457 | - /** |
|
458 | - * Retrieves a specific parameter value from the URL. |
|
459 | - * |
|
460 | - * @param string $name |
|
461 | - * @return string The parameter value, or an empty string if it does not exist. |
|
462 | - */ |
|
457 | + /** |
|
458 | + * Retrieves a specific parameter value from the URL. |
|
459 | + * |
|
460 | + * @param string $name |
|
461 | + * @return string The parameter value, or an empty string if it does not exist. |
|
462 | + */ |
|
463 | 463 | public function getParam(string $name) : string |
464 | 464 | { |
465 | 465 | return $this->info['params'][$name] ?? ''; |
466 | 466 | } |
467 | 467 | |
468 | - /** |
|
469 | - * Excludes a URL parameter entirely if present: |
|
470 | - * the parser will act as if the parameter was not |
|
471 | - * even present in the source URL, effectively |
|
472 | - * stripping it. |
|
473 | - * |
|
474 | - * @param string $name |
|
475 | - * @param string $reason A human-readable explanation why this is excluded - used when highlighting links. |
|
476 | - * @return URLInfo |
|
477 | - */ |
|
468 | + /** |
|
469 | + * Excludes a URL parameter entirely if present: |
|
470 | + * the parser will act as if the parameter was not |
|
471 | + * even present in the source URL, effectively |
|
472 | + * stripping it. |
|
473 | + * |
|
474 | + * @param string $name |
|
475 | + * @param string $reason A human-readable explanation why this is excluded - used when highlighting links. |
|
476 | + * @return URLInfo |
|
477 | + */ |
|
478 | 478 | public function excludeParam(string $name, string $reason='') : URLInfo |
479 | 479 | { |
480 | 480 | if(!isset($this->excludedParams[$name])) |
@@ -529,14 +529,14 @@ discard block |
||
529 | 529 | return self::$typeLabels[$this->getType()]; |
530 | 530 | } |
531 | 531 | |
532 | - /** |
|
533 | - * Whether excluded parameters should be highlighted in |
|
534 | - * a different color in the URL when using the |
|
535 | - * {@link URLInfo::getHighlighted()} method. |
|
536 | - * |
|
537 | - * @param bool $highlight |
|
538 | - * @return URLInfo |
|
539 | - */ |
|
532 | + /** |
|
533 | + * Whether excluded parameters should be highlighted in |
|
534 | + * a different color in the URL when using the |
|
535 | + * {@link URLInfo::getHighlighted()} method. |
|
536 | + * |
|
537 | + * @param bool $highlight |
|
538 | + * @return URLInfo |
|
539 | + */ |
|
540 | 540 | public function setHighlightExcluded(bool $highlight=true) : URLInfo |
541 | 541 | { |
542 | 542 | $this->highlightExcluded = $highlight; |
@@ -592,24 +592,24 @@ discard block |
||
592 | 592 | return $this; |
593 | 593 | } |
594 | 594 | |
595 | - /** |
|
596 | - * Whether the parameter exclusion mode is enabled: |
|
597 | - * In this case, if any parameters have been added to the |
|
598 | - * exclusion list, all relevant methods will exclude these. |
|
599 | - * |
|
600 | - * @return bool |
|
601 | - */ |
|
595 | + /** |
|
596 | + * Whether the parameter exclusion mode is enabled: |
|
597 | + * In this case, if any parameters have been added to the |
|
598 | + * exclusion list, all relevant methods will exclude these. |
|
599 | + * |
|
600 | + * @return bool |
|
601 | + */ |
|
602 | 602 | public function isParamExclusionEnabled() : bool |
603 | 603 | { |
604 | 604 | return $this->paramExclusion; |
605 | 605 | } |
606 | 606 | |
607 | - /** |
|
608 | - * Checks whether the link contains any parameters that |
|
609 | - * are on the list of excluded parameters. |
|
610 | - * |
|
611 | - * @return bool |
|
612 | - */ |
|
607 | + /** |
|
608 | + * Checks whether the link contains any parameters that |
|
609 | + * are on the list of excluded parameters. |
|
610 | + * |
|
611 | + * @return bool |
|
612 | + */ |
|
613 | 613 | public function containsExcludedParams() : bool |
614 | 614 | { |
615 | 615 | if(empty($this->excludedParams)) { |
@@ -697,26 +697,26 @@ discard block |
||
697 | 697 | ->canConnect(); |
698 | 698 | } |
699 | 699 | |
700 | - /** |
|
701 | - * Creates the connection tester instance that is used |
|
702 | - * to check if a URL can be connected to, and which is |
|
703 | - * used in the {@see URLInfo::tryConnect()} method. It |
|
704 | - * allows more settings to be used. |
|
705 | - * |
|
706 | - * @return URIConnectionTester |
|
707 | - */ |
|
700 | + /** |
|
701 | + * Creates the connection tester instance that is used |
|
702 | + * to check if a URL can be connected to, and which is |
|
703 | + * used in the {@see URLInfo::tryConnect()} method. It |
|
704 | + * allows more settings to be used. |
|
705 | + * |
|
706 | + * @return URIConnectionTester |
|
707 | + */ |
|
708 | 708 | public function createConnectionTester() : URIConnectionTester |
709 | 709 | { |
710 | 710 | return new URIConnectionTester($this); |
711 | 711 | } |
712 | 712 | |
713 | - /** |
|
714 | - * Adds/overwrites a URL parameter. |
|
715 | - * |
|
716 | - * @param string $name |
|
717 | - * @param string $val |
|
718 | - * @return URLInfo |
|
719 | - */ |
|
713 | + /** |
|
714 | + * Adds/overwrites a URL parameter. |
|
715 | + * |
|
716 | + * @param string $name |
|
717 | + * @param string $val |
|
718 | + * @return URLInfo |
|
719 | + */ |
|
720 | 720 | public function setParam(string $name, string $val) : URLInfo |
721 | 721 | { |
722 | 722 | $this->info['params'][$name] = $val; |
@@ -724,13 +724,13 @@ discard block |
||
724 | 724 | return $this; |
725 | 725 | } |
726 | 726 | |
727 | - /** |
|
728 | - * Removes a URL parameter. Has no effect if the |
|
729 | - * parameter is not present to begin with. |
|
730 | - * |
|
731 | - * @param string $param |
|
732 | - * @return URLInfo |
|
733 | - */ |
|
727 | + /** |
|
728 | + * Removes a URL parameter. Has no effect if the |
|
729 | + * parameter is not present to begin with. |
|
730 | + * |
|
731 | + * @param string $param |
|
732 | + * @return URLInfo |
|
733 | + */ |
|
734 | 734 | public function removeParam(string $param) : URLInfo |
735 | 735 | { |
736 | 736 | if(isset($this->info['params'][$param])) |
@@ -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 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $this->trimmed = trim($text); |
48 | 48 | $this->lineNumber = $lineNumber; |
49 | 49 | |
50 | - if(empty($this->trimmed)) |
|
50 | + if (empty($this->trimmed)) |
|
51 | 51 | { |
52 | 52 | $this->type = self::TYPE_EMPTY; |
53 | 53 | return; |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | |
56 | 56 | $startChar = $this->trimmed[0]; |
57 | 57 | |
58 | - if($startChar === ';') |
|
58 | + if ($startChar === ';') |
|
59 | 59 | { |
60 | 60 | $this->type = self::TYPE_COMMENT; |
61 | 61 | } |
62 | - else if($startChar === '[') |
|
62 | + else if ($startChar === '[') |
|
63 | 63 | { |
64 | 64 | $this->type = self::TYPE_SECTION_DECLARATION; |
65 | 65 | $this->sectionName = trim($this->trimmed, '[]'); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | else |
69 | 69 | { |
70 | 70 | $pos = strpos($this->trimmed, '='); |
71 | - if($pos === false) |
|
71 | + if ($pos === false) |
|
72 | 72 | { |
73 | 73 | $this->type = self::TYPE_INVALID; |
74 | 74 | return; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $this->type = self::TYPE_VALUE; |
78 | 78 | $this->varName = trim(substr($this->trimmed, 0, $pos)); |
79 | 79 | |
80 | - $this->parseValue(substr($this->trimmed, $pos+1)); |
|
80 | + $this->parseValue(substr($this->trimmed, $pos + 1)); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | $this->varValue = trim($value); |
87 | 87 | $value = $this->varValue; |
88 | 88 | |
89 | - if(empty($value)) { |
|
89 | + if (empty($value)) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
93 | - if($value[0] === '"' && $value[strlen($value) - 1] === '"') |
|
93 | + if ($value[0] === '"' && $value[strlen($value) - 1] === '"') |
|
94 | 94 | { |
95 | 95 | $value = trim($value, '"'); |
96 | 96 | $this->quoteStyle = '"'; |
97 | 97 | } |
98 | - else if($value[0] === "'" && $value[strlen($value) - 1] === "'") |
|
98 | + else if ($value[0] === "'" && $value[strlen($value) - 1] === "'") |
|
99 | 99 | { |
100 | 100 | $value = trim($value, "'"); |
101 | 101 | $this->quoteStyle = "'"; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | public function getQuotedVarValue() : string |
118 | 118 | { |
119 | - if($this->quoteStyle === '') { |
|
119 | + if ($this->quoteStyle === '') { |
|
120 | 120 | return $this->getVarValue(); |
121 | 121 | } |
122 | 122 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function setValue($value) : INILine |
177 | 177 | { |
178 | - if(!is_null($value) && !is_scalar($value)) |
|
178 | + if (!is_null($value) && !is_scalar($value)) |
|
179 | 179 | { |
180 | 180 | throw new IniHelper_Exception( |
181 | 181 | 'Cannot use non-scalar values.', |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | |
196 | 196 | public function toString() : string |
197 | 197 | { |
198 | - switch($this->type) |
|
198 | + switch ($this->type) |
|
199 | 199 | { |
200 | 200 | case self::TYPE_EMPTY: |
201 | 201 | case self::TYPE_INVALID: |
@@ -58,14 +58,12 @@ discard block |
||
58 | 58 | if($startChar === ';') |
59 | 59 | { |
60 | 60 | $this->type = self::TYPE_COMMENT; |
61 | - } |
|
62 | - else if($startChar === '[') |
|
61 | + } else if($startChar === '[') |
|
63 | 62 | { |
64 | 63 | $this->type = self::TYPE_SECTION_DECLARATION; |
65 | 64 | $this->sectionName = trim($this->trimmed, '[]'); |
66 | 65 | $this->sectionName = trim($this->sectionName); // remove any whitespace |
67 | - } |
|
68 | - else |
|
66 | + } else |
|
69 | 67 | { |
70 | 68 | $pos = strpos($this->trimmed, '='); |
71 | 69 | if($pos === false) |
@@ -94,8 +92,7 @@ discard block |
||
94 | 92 | { |
95 | 93 | $value = trim($value, '"'); |
96 | 94 | $this->quoteStyle = '"'; |
97 | - } |
|
98 | - else if($value[0] === "'" && $value[strlen($value) - 1] === "'") |
|
95 | + } else if($value[0] === "'" && $value[strlen($value) - 1] === "'") |
|
99 | 96 | { |
100 | 97 | $value = trim($value, "'"); |
101 | 98 | $this->quoteStyle = "'"; |
@@ -27,9 +27,9 @@ |
||
27 | 27 | protected RequestParam $param; |
28 | 28 | protected bool $isSubvalue = false; |
29 | 29 | |
30 | - /** |
|
31 | - * @var mixed|NULL |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var mixed|NULL |
|
32 | + */ |
|
33 | 33 | protected $value; |
34 | 34 | |
35 | 35 | public function __construct(RequestParam $param, bool $subval) |
@@ -20,7 +20,7 @@ |
||
20 | 20 | |
21 | 21 | protected function _filter() : string |
22 | 22 | { |
23 | - if(!is_scalar($this->value)) { |
|
23 | + if (!is_scalar($this->value)) { |
|
24 | 24 | return ''; |
25 | 25 | } |
26 | 26 |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | */ |
27 | 27 | protected function _filter() : array |
28 | 28 | { |
29 | - if(is_array($this->value)) { |
|
29 | + if (is_array($this->value)) { |
|
30 | 30 | return $this->value; |
31 | 31 | } |
32 | 32 | |
33 | - if($this->value === '' || !is_string($this->value)) { |
|
33 | + if ($this->value === '' || !is_string($this->value)) { |
|
34 | 34 | return array(); |
35 | 35 | } |
36 | 36 | |
@@ -38,19 +38,19 @@ discard block |
||
38 | 38 | $stripEmptyEntries = $this->getBoolOption('stripEmptyEntries'); |
39 | 39 | $result = explode(',', $this->value); |
40 | 40 | |
41 | - if(!$trimEntries && !$stripEmptyEntries) { |
|
41 | + if (!$trimEntries && !$stripEmptyEntries) { |
|
42 | 42 | return $result; |
43 | 43 | } |
44 | 44 | |
45 | 45 | $keep = array(); |
46 | 46 | |
47 | - foreach($result as $entry) |
|
47 | + foreach ($result as $entry) |
|
48 | 48 | { |
49 | - if($trimEntries === true) { |
|
49 | + if ($trimEntries === true) { |
|
50 | 50 | $entry = trim($entry); |
51 | 51 | } |
52 | 52 | |
53 | - if($stripEmptyEntries === true && $entry === '') { |
|
53 | + if ($stripEmptyEntries === true && $entry === '') { |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 |
@@ -32,7 +32,7 @@ |
||
32 | 32 | */ |
33 | 33 | protected function _validate() |
34 | 34 | { |
35 | - if(in_array($this->value, $this->getArrayOption('values'), true)) { |
|
35 | + if (in_array($this->value, $this->getArrayOption('values'), true)) { |
|
36 | 36 | return $this->value; |
37 | 37 | } |
38 | 38 |
@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | protected function _validate() : ?int |
32 | 32 | { |
33 | - if(ConvertHelper::isInteger($this->value)) { |
|
33 | + if (ConvertHelper::isInteger($this->value)) { |
|
34 | 34 | return (int)$this->value; |
35 | 35 | } |
36 | 36 |