@@ -156,26 +156,26 @@ discard block |
||
156 | 156 | |
157 | 157 | $this->filterParsed(); |
158 | 158 | |
159 | - if($this->detectEmail()) { |
|
159 | + if ($this->detectEmail()) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | - if($this->detectFragmentLink()) { |
|
163 | + if ($this->detectFragmentLink()) { |
|
164 | 164 | return; |
165 | 165 | } |
166 | 166 | |
167 | - if($this->detectPhoneLink()) { |
|
167 | + if ($this->detectPhoneLink()) { |
|
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | - if(!$this->isValid) { |
|
171 | + if (!$this->isValid) { |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | |
175 | 175 | // no scheme found: it may be an email address without the mailto: |
176 | 176 | // It can't be a variable, since without the scheme it would already |
177 | 177 | // have been recognized as a vaiable only link. |
178 | - if(!isset($this->info['scheme'])) { |
|
178 | + if (!isset($this->info['scheme'])) { |
|
179 | 179 | $this->setError( |
180 | 180 | self::ERROR_MISSING_SCHEME, |
181 | 181 | t('Cannot determine the link\'s scheme, e.g. %1$s.', 'http') |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | return; |
185 | 185 | } |
186 | 186 | |
187 | - if(!in_array($this->info['scheme'], $this->knownSchemes)) { |
|
187 | + if (!in_array($this->info['scheme'], $this->knownSchemes)) { |
|
188 | 188 | $this->setError( |
189 | 189 | self::ERROR_INVALID_SCHEME, |
190 | - t('The scheme %1$s is not supported for links.', $this->info['scheme']) . ' ' . |
|
190 | + t('The scheme %1$s is not supported for links.', $this->info['scheme']).' '. |
|
191 | 191 | t('Valid schemes are: %1$s.', implode(', ', $this->knownSchemes)) |
192 | 192 | ); |
193 | 193 | $this->isValid = false; |
@@ -197,17 +197,17 @@ discard block |
||
197 | 197 | // every link needs a host. This case can happen for ex, if |
198 | 198 | // the link starts with a typo with only one slash, like: |
199 | 199 | // "http:/hostname" |
200 | - if(!isset($this->info['host'])) { |
|
200 | + if (!isset($this->info['host'])) { |
|
201 | 201 | $this->setError( |
202 | 202 | self::ERROR_MISSING_HOST, |
203 | - t('Cannot determine the link\'s host name.') . ' ' . |
|
203 | + t('Cannot determine the link\'s host name.').' '. |
|
204 | 204 | t('This usually happens when there\'s a typo somewhere.') |
205 | 205 | ); |
206 | 206 | $this->isValid = false; |
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
210 | - if(!empty($this->info['query'])) |
|
210 | + if (!empty($this->info['query'])) |
|
211 | 211 | { |
212 | 212 | $this->params = \AppUtils\ConvertHelper::parseQueryString($this->info['query']); |
213 | 213 | ksort($this->params); |
@@ -252,30 +252,30 @@ discard block |
||
252 | 252 | */ |
253 | 253 | protected function filterParsed() |
254 | 254 | { |
255 | - foreach($this->info as $key => $val) |
|
255 | + foreach ($this->info as $key => $val) |
|
256 | 256 | { |
257 | - if(is_string($val)) { |
|
257 | + if (is_string($val)) { |
|
258 | 258 | $this->info[$key] = trim($val); |
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | - if(isset($this->info['host'])) { |
|
262 | + if (isset($this->info['host'])) { |
|
263 | 263 | $this->info['host'] = str_replace(' ', '', $this->info['host']); |
264 | 264 | } |
265 | 265 | |
266 | - if(isset($this->info['path'])) { |
|
266 | + if (isset($this->info['path'])) { |
|
267 | 267 | $this->info['path'] = str_replace(' ', '', $this->info['path']); |
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
271 | 271 | protected function detectEmail() |
272 | 272 | { |
273 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
273 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
274 | 274 | $this->isEmail = true; |
275 | 275 | return true; |
276 | 276 | } |
277 | 277 | |
278 | - if(isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
278 | + if (isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
279 | 279 | { |
280 | 280 | $this->info['scheme'] = 'email'; |
281 | 281 | $this->isEmail = true; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | |
288 | 288 | protected function detectFragmentLink() |
289 | 289 | { |
290 | - if(isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
290 | + if (isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
291 | 291 | $this->isFragment = true; |
292 | 292 | return true; |
293 | 293 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | |
298 | 298 | protected function detectPhoneLink() |
299 | 299 | { |
300 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
300 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
301 | 301 | $this->isPhone = true; |
302 | 302 | return true; |
303 | 303 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function isSecure() |
313 | 313 | { |
314 | - if(isset($this->info['scheme']) && $this->info['scheme']=='https') { |
|
314 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'https') { |
|
315 | 315 | return true; |
316 | 316 | } |
317 | 317 | |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | public function getPort() : int |
387 | 387 | { |
388 | 388 | $port = $this->getInfoKey('port'); |
389 | - if(!empty($port)) { |
|
389 | + if (!empty($port)) { |
|
390 | 390 | return (int)$port; |
391 | 391 | } |
392 | 392 | |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | |
467 | 467 | protected function getInfoKey(string $name) : string |
468 | 468 | { |
469 | - if(isset($this->info[$name])) { |
|
469 | + if (isset($this->info[$name])) { |
|
470 | 470 | return (string)$this->info[$name]; |
471 | 471 | } |
472 | 472 | |
@@ -475,34 +475,34 @@ discard block |
||
475 | 475 | |
476 | 476 | public function getNormalized() : string |
477 | 477 | { |
478 | - if(!$this->isValid) { |
|
478 | + if (!$this->isValid) { |
|
479 | 479 | return ''; |
480 | 480 | } |
481 | 481 | |
482 | - if($this->isFragment === true) |
|
482 | + if ($this->isFragment === true) |
|
483 | 483 | { |
484 | 484 | return '#'.$this->getFragment(); |
485 | 485 | } |
486 | - else if($this->isPhone === true) |
|
486 | + else if ($this->isPhone === true) |
|
487 | 487 | { |
488 | 488 | return 'tel://'.$this->getHost(); |
489 | 489 | } |
490 | - else if($this->isEmail === true) |
|
490 | + else if ($this->isEmail === true) |
|
491 | 491 | { |
492 | 492 | return 'mailto:'.$this->getPath(); |
493 | 493 | } |
494 | 494 | |
495 | 495 | $normalized = $this->info['scheme'].'://'.$this->info['host']; |
496 | - if(isset($this->info['path'])) { |
|
496 | + if (isset($this->info['path'])) { |
|
497 | 497 | $normalized .= $this->info['path']; |
498 | 498 | } |
499 | 499 | |
500 | 500 | $params = $this->getParams(); |
501 | - if(!empty($params)) { |
|
501 | + if (!empty($params)) { |
|
502 | 502 | $normalized .= '?'.http_build_query($params); |
503 | 503 | } |
504 | 504 | |
505 | - if(isset($this->info['fragment'])) { |
|
505 | + if (isset($this->info['fragment'])) { |
|
506 | 506 | $normalized .= '#'.$this->info['fragment']; |
507 | 507 | } |
508 | 508 | |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | */ |
531 | 531 | public function getHighlighted() : string |
532 | 532 | { |
533 | - if(!$this->isValid) { |
|
533 | + if (!$this->isValid) { |
|
534 | 534 | return ''; |
535 | 535 | } |
536 | 536 | |
537 | - if($this->isEmail) { |
|
537 | + if ($this->isEmail) { |
|
538 | 538 | return sprintf( |
539 | 539 | '<span class="link-scheme scheme-mailto">mailto:</span>'. |
540 | 540 | '<span class="link-host">%s</span>', |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | ); |
543 | 543 | } |
544 | 544 | |
545 | - if($this->isFragment) { |
|
545 | + if ($this->isFragment) { |
|
546 | 546 | return sprintf( |
547 | 547 | '<span class="link-fragment-sign">#</span>'. |
548 | 548 | '<span class="link-fragment-value">%s</span>', |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | $result = ''; |
554 | 554 | |
555 | - if($this->hasScheme()) |
|
555 | + if ($this->hasScheme()) |
|
556 | 556 | { |
557 | 557 | $result = sprintf( |
558 | 558 | '<span class="link-scheme scheme-%1$s">'. |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | |
565 | 565 | $result .= '<span class="link-component double-slashes">//</span>'; |
566 | 566 | |
567 | - if($this->hasUsername()) |
|
567 | + if ($this->hasUsername()) |
|
568 | 568 | { |
569 | 569 | $result .= sprintf( |
570 | 570 | '<span class="link-credentials">%s</span>'. |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | ); |
577 | 577 | } |
578 | 578 | |
579 | - if($this->hasHost()) |
|
579 | + if ($this->hasHost()) |
|
580 | 580 | { |
581 | 581 | $result .= |
582 | 582 | sprintf( |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | ); |
586 | 586 | } |
587 | 587 | |
588 | - if($this->hasPort()) |
|
588 | + if ($this->hasPort()) |
|
589 | 589 | { |
590 | 590 | $result .= sprintf( |
591 | 591 | '<span class="link-component port-separator">:</span>'. |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | ); |
595 | 595 | } |
596 | 596 | |
597 | - if($this->hasPath()) |
|
597 | + if ($this->hasPath()) |
|
598 | 598 | { |
599 | 599 | $path = str_replace(array(';', '='), array(';<wbr>', '=<wbr>'), $this->getPath()); |
600 | 600 | $tokens = explode('/', $path); |
@@ -605,11 +605,11 @@ discard block |
||
605 | 605 | ); |
606 | 606 | } |
607 | 607 | |
608 | - if(!empty($this->params)) |
|
608 | + if (!empty($this->params)) |
|
609 | 609 | { |
610 | 610 | $tokens = array(); |
611 | 611 | |
612 | - foreach($this->params as $param => $value) |
|
612 | + foreach ($this->params as $param => $value) |
|
613 | 613 | { |
614 | 614 | $parts = sprintf( |
615 | 615 | '<span class="link-param-name">%s</span>'. |
@@ -627,10 +627,10 @@ discard block |
||
627 | 627 | $tag = ''; |
628 | 628 | |
629 | 629 | // is parameter exclusion enabled, and is this an excluded parameter? |
630 | - if($this->paramExclusion && isset($this->excludedParams[$param])) |
|
630 | + if ($this->paramExclusion && isset($this->excludedParams[$param])) |
|
631 | 631 | { |
632 | 632 | // display the excluded parameter, but highlight it |
633 | - if($this->highlightExcluded) |
|
633 | + if ($this->highlightExcluded) |
|
634 | 634 | { |
635 | 635 | $tooltip = $this->excludedParams[$param]; |
636 | 636 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | '<span class="link-component query-sign">?</span>'.implode('<span class="link-component param-separator">&</span>', $tokens); |
661 | 661 | } |
662 | 662 | |
663 | - if(isset($this->info['fragment'])) { |
|
663 | + if (isset($this->info['fragment'])) { |
|
664 | 664 | $result .= sprintf( |
665 | 665 | '<span class="link-fragment-sign">#</span>'. |
666 | 666 | '<span class="link-fragment">%s</span>', |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | |
684 | 684 | public function getErrorMessage() : string |
685 | 685 | { |
686 | - if(isset($this->error)) { |
|
686 | + if (isset($this->error)) { |
|
687 | 687 | return $this->error['message']; |
688 | 688 | } |
689 | 689 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | |
693 | 693 | public function getErrorCode() : int |
694 | 694 | { |
695 | - if(isset($this->error)) { |
|
695 | + if (isset($this->error)) { |
|
696 | 696 | return $this->error['code']; |
697 | 697 | } |
698 | 698 | |
@@ -722,13 +722,13 @@ discard block |
||
722 | 722 | */ |
723 | 723 | public function getParams() : array |
724 | 724 | { |
725 | - if(!$this->paramExclusion || empty($this->excludedParams)) { |
|
725 | + if (!$this->paramExclusion || empty($this->excludedParams)) { |
|
726 | 726 | return $this->params; |
727 | 727 | } |
728 | 728 | |
729 | 729 | $keep = array(); |
730 | - foreach($this->params as $name => $value) { |
|
731 | - if(!isset($this->excludedParams[$name])) { |
|
730 | + foreach ($this->params as $name => $value) { |
|
731 | + if (!isset($this->excludedParams[$name])) { |
|
732 | 732 | $keep[$name] = $value; |
733 | 733 | } |
734 | 734 | } |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | */ |
755 | 755 | public function getParam(string $name) : string |
756 | 756 | { |
757 | - if(isset($this->params[$name])) { |
|
757 | + if (isset($this->params[$name])) { |
|
758 | 758 | return $this->params[$name]; |
759 | 759 | } |
760 | 760 | |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | */ |
774 | 774 | public function excludeParam(string $name, string $reason) : URLInfo |
775 | 775 | { |
776 | - if(!isset($this->excludedParams[$name])) |
|
776 | + if (!isset($this->excludedParams[$name])) |
|
777 | 777 | { |
778 | 778 | $this->excludedParams[$name] = $reason; |
779 | 779 | $this->setParamExclusion(); |
@@ -794,15 +794,15 @@ discard block |
||
794 | 794 | */ |
795 | 795 | public function getType() : string |
796 | 796 | { |
797 | - if($this->isEmail) { |
|
797 | + if ($this->isEmail) { |
|
798 | 798 | return self::TYPE_EMAIL; |
799 | 799 | } |
800 | 800 | |
801 | - if($this->isFragment) { |
|
801 | + if ($this->isFragment) { |
|
802 | 802 | return self::TYPE_FRAGMENT; |
803 | 803 | } |
804 | 804 | |
805 | - if($this->isPhone) { |
|
805 | + if ($this->isPhone) { |
|
806 | 806 | return self::TYPE_PHONE; |
807 | 807 | } |
808 | 808 | |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | |
812 | 812 | public function getTypeLabel() : string |
813 | 813 | { |
814 | - if(!isset(self::$typeLabels)) |
|
814 | + if (!isset(self::$typeLabels)) |
|
815 | 815 | { |
816 | 816 | self::$typeLabels = array( |
817 | 817 | self::TYPE_EMAIL => t('Email'), |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | |
824 | 824 | $type = $this->getType(); |
825 | 825 | |
826 | - if(!isset(self::$typeLabels[$type])) |
|
826 | + if (!isset(self::$typeLabels[$type])) |
|
827 | 827 | { |
828 | 828 | throw new BaseException( |
829 | 829 | sprintf('Unknown URL type label for type [%s].', $type), |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * @param bool $highlight |
844 | 844 | * @return URLInfo |
845 | 845 | */ |
846 | - public function setHighlightExcluded(bool $highlight=true) : URLInfo |
|
846 | + public function setHighlightExcluded(bool $highlight = true) : URLInfo |
|
847 | 847 | { |
848 | 848 | $this->highlightExcluded = $highlight; |
849 | 849 | return $this; |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | * @see URLInfo::isParamExclusionEnabled() |
892 | 892 | * @see URLInfo::setHighlightExcluded() |
893 | 893 | */ |
894 | - public function setParamExclusion(bool $enabled=true) : URLInfo |
|
894 | + public function setParamExclusion(bool $enabled = true) : URLInfo |
|
895 | 895 | { |
896 | 896 | $this->paramExclusion = $enabled; |
897 | 897 | return $this; |
@@ -917,13 +917,13 @@ discard block |
||
917 | 917 | */ |
918 | 918 | public function containsExcludedParams() : bool |
919 | 919 | { |
920 | - if(empty($this->excludedParams)) { |
|
920 | + if (empty($this->excludedParams)) { |
|
921 | 921 | return false; |
922 | 922 | } |
923 | 923 | |
924 | 924 | $names = array_keys($this->params); |
925 | - foreach($names as $name) { |
|
926 | - if(isset($this->excludedParams[$name])) { |
|
925 | + foreach ($names as $name) { |
|
926 | + if (isset($this->excludedParams[$name])) { |
|
927 | 927 | return true; |
928 | 928 | } |
929 | 929 | } |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | |
940 | 940 | public function offsetSet($offset, $value) |
941 | 941 | { |
942 | - if(in_array($offset, $this->infoKeys)) { |
|
942 | + if (in_array($offset, $this->infoKeys)) { |
|
943 | 943 | $this->info[$offset] = $value; |
944 | 944 | } |
945 | 945 | } |
@@ -956,11 +956,11 @@ discard block |
||
956 | 956 | |
957 | 957 | public function offsetGet($offset) |
958 | 958 | { |
959 | - if($offset === 'port') { |
|
959 | + if ($offset === 'port') { |
|
960 | 960 | return $this->getPort(); |
961 | 961 | } |
962 | 962 | |
963 | - if(in_array($offset, $this->infoKeys)) { |
|
963 | + if (in_array($offset, $this->infoKeys)) { |
|
964 | 964 | return $this->getInfoKey($offset); |
965 | 965 | } |
966 | 966 | |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | { |
972 | 972 | $cssFolder = realpath(__DIR__.'/../css'); |
973 | 973 | |
974 | - if($cssFolder === false) { |
|
974 | + if ($cssFolder === false) { |
|
975 | 975 | throw new BaseException( |
976 | 976 | 'Cannot find package CSS folder.', |
977 | 977 | null, |