@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param bool $enable Whether to turn it on or off. |
40 | 40 | * @return URLInfo_Normalizer |
41 | 41 | */ |
42 | - public function enableAuth(bool $enable=true) : URLInfo_Normalizer |
|
42 | + public function enableAuth(bool $enable = true) : URLInfo_Normalizer |
|
43 | 43 | { |
44 | 44 | $this->auth = $enable; |
45 | 45 | return $this; |
@@ -86,48 +86,48 @@ discard block |
||
86 | 86 | |
87 | 87 | protected function renderAuth(string $normalized) : string |
88 | 88 | { |
89 | - if(!$this->info->hasUsername() || !$this->auth) { |
|
89 | + if (!$this->info->hasUsername() || !$this->auth) { |
|
90 | 90 | return $normalized; |
91 | 91 | } |
92 | 92 | |
93 | - return $normalized . urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@'; |
|
93 | + return $normalized.urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@'; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | protected function renderPort(string $normalized) : string |
97 | 97 | { |
98 | - if(!$this->info->hasPort()) { |
|
98 | + if (!$this->info->hasPort()) { |
|
99 | 99 | return $normalized; |
100 | 100 | } |
101 | 101 | |
102 | - return $normalized . ':'.$this->info->getPort(); |
|
102 | + return $normalized.':'.$this->info->getPort(); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | protected function renderPath(string $normalized) : string |
106 | 106 | { |
107 | - if(!$this->info->hasPath()) { |
|
107 | + if (!$this->info->hasPath()) { |
|
108 | 108 | return $normalized; |
109 | 109 | } |
110 | 110 | |
111 | - return $normalized . $this->info->getPath(); |
|
111 | + return $normalized.$this->info->getPath(); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | protected function renderParams(string $normalized) : string |
115 | 115 | { |
116 | 116 | $params = $this->info->getParams(); |
117 | 117 | |
118 | - if(empty($params)) { |
|
118 | + if (empty($params)) { |
|
119 | 119 | return $normalized; |
120 | 120 | } |
121 | 121 | |
122 | - return $normalized . '?'.http_build_query($params, null, '&', PHP_QUERY_RFC3986); |
|
122 | + return $normalized.'?'.http_build_query($params, null, '&', PHP_QUERY_RFC3986); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | protected function renderFragment(string $normalized) : string |
126 | 126 | { |
127 | - if(!$this->info->hasFragment()) { |
|
127 | + if (!$this->info->hasFragment()) { |
|
128 | 128 | return $normalized; |
129 | 129 | } |
130 | 130 | |
131 | - return $normalized . '#'.$this->info->getFragment(); |
|
131 | + return $normalized.'#'.$this->info->getFragment(); |
|
132 | 132 | } |
133 | 133 | } |
@@ -38,24 +38,24 @@ discard block |
||
38 | 38 | */ |
39 | 39 | class NumberInfo |
40 | 40 | { |
41 | - /** |
|
42 | - * @var mixed |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var mixed |
|
43 | + */ |
|
44 | 44 | protected $rawValue; |
45 | 45 | |
46 | - /** |
|
47 | - * @var array |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var array |
|
48 | + */ |
|
49 | 49 | protected $info; |
50 | 50 | |
51 | - /** |
|
52 | - * @var bool |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var bool |
|
53 | + */ |
|
54 | 54 | protected $empty = false; |
55 | 55 | |
56 | - /** |
|
57 | - * @var array |
|
58 | - */ |
|
56 | + /** |
|
57 | + * @var array |
|
58 | + */ |
|
59 | 59 | protected $knownUnits = array( |
60 | 60 | '%' => true, |
61 | 61 | 'rem' => true, |
@@ -95,21 +95,21 @@ discard block |
||
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
98 | - /** |
|
99 | - * Retrieves the raw, internal information array resulting |
|
100 | - * from the parsing of the number. |
|
101 | - * |
|
102 | - * @return array |
|
103 | - */ |
|
98 | + /** |
|
99 | + * Retrieves the raw, internal information array resulting |
|
100 | + * from the parsing of the number. |
|
101 | + * |
|
102 | + * @return array |
|
103 | + */ |
|
104 | 104 | public function getRawInfo() : array |
105 | 105 | { |
106 | 106 | return $this->info; |
107 | 107 | } |
108 | 108 | |
109 | - /** |
|
110 | - * Whether the number was empty (null or empty string). |
|
111 | - * @return boolean |
|
112 | - */ |
|
109 | + /** |
|
110 | + * Whether the number was empty (null or empty string). |
|
111 | + * @return boolean |
|
112 | + */ |
|
113 | 113 | public function isEmpty() : bool |
114 | 114 | { |
115 | 115 | return $this->empty; |
@@ -532,12 +532,12 @@ discard block |
||
532 | 532 | return $cache[$key]; |
533 | 533 | } |
534 | 534 | |
535 | - /** |
|
536 | - * Parses a string number notation with units included, e.g. 14px, 50%... |
|
537 | - * |
|
538 | - * @param string $test |
|
539 | - * @return array |
|
540 | - */ |
|
535 | + /** |
|
536 | + * Parses a string number notation with units included, e.g. 14px, 50%... |
|
537 | + * |
|
538 | + * @param string $test |
|
539 | + * @return array |
|
540 | + */ |
|
541 | 541 | private function parseStringValue(string $test) : array |
542 | 542 | { |
543 | 543 | $number = null; |
@@ -588,13 +588,13 @@ discard block |
||
588 | 588 | return $this->filterInfo($result); |
589 | 589 | } |
590 | 590 | |
591 | - /** |
|
592 | - * Attempts to determine what kind of units are specified |
|
593 | - * in the string. Returns NULL if none could be matched. |
|
594 | - * |
|
595 | - * @param string $value |
|
596 | - * @return array|NULL |
|
597 | - */ |
|
591 | + /** |
|
592 | + * Attempts to determine what kind of units are specified |
|
593 | + * in the string. Returns NULL if none could be matched. |
|
594 | + * |
|
595 | + * @param string $value |
|
596 | + * @return array|NULL |
|
597 | + */ |
|
598 | 598 | private function findUnits(string $value) : ?array |
599 | 599 | { |
600 | 600 | $vlength = strlen($value); |
@@ -622,12 +622,12 @@ discard block |
||
622 | 622 | return null; |
623 | 623 | } |
624 | 624 | |
625 | - /** |
|
626 | - * Creates the cache key for the specified value. |
|
627 | - * |
|
628 | - * @param mixed $value |
|
629 | - * @return string |
|
630 | - */ |
|
625 | + /** |
|
626 | + * Creates the cache key for the specified value. |
|
627 | + * |
|
628 | + * @param mixed $value |
|
629 | + * @return string |
|
630 | + */ |
|
631 | 631 | private function createValueKey($value) : string |
632 | 632 | { |
633 | 633 | if(!is_string($value) && !is_numeric($value)) |
@@ -640,59 +640,59 @@ discard block |
||
640 | 640 | |
641 | 641 | protected $postProcess = false; |
642 | 642 | |
643 | - /** |
|
644 | - * Called if explicitly enabled: allows filtering the |
|
645 | - * number after the detection process has completed. |
|
646 | - * |
|
647 | - * @param string|NULL $number The adjusted number |
|
648 | - * @param string $originalString The original value before it was parsed |
|
649 | - * @return mixed |
|
650 | - */ |
|
643 | + /** |
|
644 | + * Called if explicitly enabled: allows filtering the |
|
645 | + * number after the detection process has completed. |
|
646 | + * |
|
647 | + * @param string|NULL $number The adjusted number |
|
648 | + * @param string $originalString The original value before it was parsed |
|
649 | + * @return mixed |
|
650 | + */ |
|
651 | 651 | protected function postProcess(?string $number, /** @scrutinizer ignore-unused */ string $originalString) |
652 | 652 | { |
653 | 653 | return $number; |
654 | 654 | } |
655 | 655 | |
656 | - /** |
|
657 | - * Filters the value before it is parsed, but only if it is a string. |
|
658 | - * |
|
659 | - * NOTE: This may be overwritten in a subclass, to allow custom filtering |
|
660 | - * the the values. An example of a use case would be a preprocessor for |
|
661 | - * variables in a templating system. |
|
662 | - * |
|
663 | - * @param string $trimmedString The trimmed value. |
|
664 | - * @param array $cache The internal values cache array. |
|
665 | - * @param string $originalValue The original value that the NumberInfo was created for. |
|
666 | - * @return string |
|
667 | - * |
|
668 | - * @see NumberInfo::enablePostProcess() |
|
669 | - */ |
|
656 | + /** |
|
657 | + * Filters the value before it is parsed, but only if it is a string. |
|
658 | + * |
|
659 | + * NOTE: This may be overwritten in a subclass, to allow custom filtering |
|
660 | + * the the values. An example of a use case would be a preprocessor for |
|
661 | + * variables in a templating system. |
|
662 | + * |
|
663 | + * @param string $trimmedString The trimmed value. |
|
664 | + * @param array $cache The internal values cache array. |
|
665 | + * @param string $originalValue The original value that the NumberInfo was created for. |
|
666 | + * @return string |
|
667 | + * |
|
668 | + * @see NumberInfo::enablePostProcess() |
|
669 | + */ |
|
670 | 670 | protected function preProcess(string $trimmedString, /** @scrutinizer ignore-unused */ array &$cache, /** @scrutinizer ignore-unused */ string $originalValue) : string |
671 | 671 | { |
672 | 672 | return str_replace(',', '.', $trimmedString); |
673 | 673 | } |
674 | 674 | |
675 | - /** |
|
676 | - * Enables the post processing so the postProcess method gets called. |
|
677 | - * This should be called in the {@link NumberInfo::preProcess()} |
|
678 | - * method as needed. |
|
679 | - * |
|
680 | - * @return NumberInfo |
|
681 | - * @see NumberInfo::postProcess() |
|
682 | - */ |
|
675 | + /** |
|
676 | + * Enables the post processing so the postProcess method gets called. |
|
677 | + * This should be called in the {@link NumberInfo::preProcess()} |
|
678 | + * method as needed. |
|
679 | + * |
|
680 | + * @return NumberInfo |
|
681 | + * @see NumberInfo::postProcess() |
|
682 | + */ |
|
683 | 683 | protected function enablePostProcess() : NumberInfo |
684 | 684 | { |
685 | 685 | $this->postProcess = true; |
686 | 686 | return $this; |
687 | 687 | } |
688 | 688 | |
689 | - /** |
|
690 | - * Filters the number info array to adjust the units |
|
691 | - * and number according to the required rules. |
|
692 | - * |
|
693 | - * @param array $info |
|
694 | - * @return array |
|
695 | - */ |
|
689 | + /** |
|
690 | + * Filters the number info array to adjust the units |
|
691 | + * and number according to the required rules. |
|
692 | + * |
|
693 | + * @param array $info |
|
694 | + * @return array |
|
695 | + */ |
|
696 | 696 | protected function filterInfo(array $info) : array |
697 | 697 | { |
698 | 698 | $useUnits = 'px'; |