@@ -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'; |
@@ -27,16 +27,16 @@ |
||
27 | 27 | |
28 | 28 | } |
29 | 29 | |
30 | - /** |
|
31 | - * We parse the query string ourselves, because the PHP implementation |
|
32 | - * of parse_str has limitations that do not apply to query strings. This |
|
33 | - * is due to the fact that parse_str has to create PHP-compatible variable |
|
34 | - * names from the parameters. URL parameters simply allow way more things |
|
35 | - * than PHP variable names. |
|
36 | - * |
|
37 | - * @param string $queryString |
|
38 | - * @return array |
|
39 | - */ |
|
30 | + /** |
|
31 | + * We parse the query string ourselves, because the PHP implementation |
|
32 | + * of parse_str has limitations that do not apply to query strings. This |
|
33 | + * is due to the fact that parse_str has to create PHP-compatible variable |
|
34 | + * names from the parameters. URL parameters simply allow way more things |
|
35 | + * than PHP variable names. |
|
36 | + * |
|
37 | + * @param string $queryString |
|
38 | + * @return array |
|
39 | + */ |
|
40 | 40 | public function parse(string $queryString) : array |
41 | 41 | { |
42 | 42 | // allow HTML entities notation |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | { |
23 | 23 | const ERROR_MALFORMATTED_STRING = 53801; |
24 | 24 | |
25 | - /** |
|
26 | - * @var string[] |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var string[] |
|
27 | + */ |
|
28 | 28 | protected static $controlChars = array( |
29 | 29 | '0000-0008', // control chars |
30 | 30 | '000E-000F', // control chars |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | '2000-200F', // non-breaking space and co |
33 | 33 | ); |
34 | 34 | |
35 | - /** |
|
36 | - * @var string|NULL |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var string|NULL |
|
37 | + */ |
|
38 | 38 | protected static $controlCharsRegex; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string[] |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var string[] |
|
42 | + */ |
|
43 | 43 | protected static $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
44 | 44 | |
45 | - /** |
|
46 | - * @var string[]|NULL |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var string[]|NULL |
|
47 | + */ |
|
48 | 48 | protected static $charsAsHex; |
49 | 49 | |
50 | 50 | public function __construct() |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - /** |
|
71 | - * Retrieves the HEX character codes for all control |
|
72 | - * characters that the {@link stripControlCharacters()} |
|
73 | - * method will remove. |
|
74 | - * |
|
75 | - * @return string[] |
|
76 | - */ |
|
70 | + /** |
|
71 | + * Retrieves the HEX character codes for all control |
|
72 | + * characters that the {@link stripControlCharacters()} |
|
73 | + * method will remove. |
|
74 | + * |
|
75 | + * @return string[] |
|
76 | + */ |
|
77 | 77 | public function getCharsAsHex() : array |
78 | 78 | { |
79 | 79 | if (isset(self::$charsAsHex)) |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | return $stack; |
121 | 121 | } |
122 | 122 | |
123 | - /** |
|
124 | - * Retrieves an array of all control characters that |
|
125 | - * the {@link stripControlCharacters()} method will |
|
126 | - * remove, as the actual UTF-8 characters. |
|
127 | - * |
|
128 | - * @return string[] |
|
129 | - */ |
|
123 | + /** |
|
124 | + * Retrieves an array of all control characters that |
|
125 | + * the {@link stripControlCharacters()} method will |
|
126 | + * remove, as the actual UTF-8 characters. |
|
127 | + * |
|
128 | + * @return string[] |
|
129 | + */ |
|
130 | 130 | public function getCharsAsUTF8() : array |
131 | 131 | { |
132 | 132 | $chars = $this->getCharsAsHex(); |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | return $result; |
140 | 140 | } |
141 | 141 | |
142 | - /** |
|
143 | - * Retrieves all control characters as JSON encoded |
|
144 | - * characters, e.g. "\u200b". |
|
145 | - * |
|
146 | - * @return string[] |
|
147 | - */ |
|
142 | + /** |
|
143 | + * Retrieves all control characters as JSON encoded |
|
144 | + * characters, e.g. "\u200b". |
|
145 | + * |
|
146 | + * @return string[] |
|
147 | + */ |
|
148 | 148 | public function getCharsAsJSON() : array |
149 | 149 | { |
150 | 150 | $chars = $this->getCharsAsHex(); |
@@ -157,17 +157,17 @@ discard block |
||
157 | 157 | return $result; |
158 | 158 | } |
159 | 159 | |
160 | - /** |
|
161 | - * Removes all control characters from the specified string |
|
162 | - * that can cause problems in some cases, like creating |
|
163 | - * valid XML documents. This includes invisible non-breaking |
|
164 | - * spaces. |
|
165 | - * |
|
166 | - * @param string $string |
|
167 | - * @return string |
|
168 | - * @see https://stackoverflow.com/a/8171868/2298192 |
|
169 | - * @see https://unicode-table.com/en |
|
170 | - */ |
|
160 | + /** |
|
161 | + * Removes all control characters from the specified string |
|
162 | + * that can cause problems in some cases, like creating |
|
163 | + * valid XML documents. This includes invisible non-breaking |
|
164 | + * spaces. |
|
165 | + * |
|
166 | + * @param string $string |
|
167 | + * @return string |
|
168 | + * @see https://stackoverflow.com/a/8171868/2298192 |
|
169 | + * @see https://unicode-table.com/en |
|
170 | + */ |
|
171 | 171 | public function stripControlCharacters(string $string) : string |
172 | 172 | { |
173 | 173 | if(empty($string)) |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | { |
23 | 23 | const ERROR_NO_BOUNDARIES_SPECIFIED = 44401; |
24 | 24 | |
25 | - /** |
|
26 | - * @var RequestHelper |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var RequestHelper |
|
27 | + */ |
|
28 | 28 | protected $helper; |
29 | 29 | |
30 | - /** |
|
31 | - * @var RequestHelper_Boundaries_Boundary[] |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var RequestHelper_Boundaries_Boundary[] |
|
32 | + */ |
|
33 | 33 | protected $boundaries = array(); |
34 | 34 | |
35 | - /** |
|
36 | - * @var integer |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var integer |
|
37 | + */ |
|
38 | 38 | protected $contentLength = 0; |
39 | 39 | |
40 | 40 | public function __construct(RequestHelper $helper) |
@@ -42,31 +42,31 @@ discard block |
||
42 | 42 | $this->helper = $helper; |
43 | 43 | } |
44 | 44 | |
45 | - /** |
|
46 | - * Retrieves the string that is used to separate mime boundaries in the body. |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
45 | + /** |
|
46 | + * Retrieves the string that is used to separate mime boundaries in the body. |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | 50 | public function getMimeBoundary() : string |
51 | 51 | { |
52 | 52 | return $this->helper->getMimeBoundary(); |
53 | 53 | } |
54 | 54 | |
55 | - /** |
|
56 | - * Retrieves the end of line character(s) used in the body. |
|
57 | - * |
|
58 | - * @return string |
|
59 | - */ |
|
55 | + /** |
|
56 | + * Retrieves the end of line character(s) used in the body. |
|
57 | + * |
|
58 | + * @return string |
|
59 | + */ |
|
60 | 60 | public function getEOL() : string |
61 | 61 | { |
62 | 62 | return $this->helper->getEOL(); |
63 | 63 | } |
64 | 64 | |
65 | - /** |
|
66 | - * Retrieves the total content length of all boundary contents. |
|
67 | - * |
|
68 | - * @return int |
|
69 | - */ |
|
65 | + /** |
|
66 | + * Retrieves the total content length of all boundary contents. |
|
67 | + * |
|
68 | + * @return int |
|
69 | + */ |
|
70 | 70 | public function getContentLength() : int |
71 | 71 | { |
72 | 72 | // this must use strlen, and not mb_strlen: the content length |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | return strlen($this->render()); |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * Adds a file to be sent with the request. |
|
80 | - * |
|
81 | - * @param string $varName The variable name to send the file in |
|
82 | - * @param string $fileName The name of the file as it should be received at the destination |
|
83 | - * @param string $content The raw content of the file |
|
84 | - * @param string $contentType The content type, use the constants to specify this |
|
85 | - * @param string $encoding The encoding of the file, use the constants to specify this |
|
86 | - */ |
|
78 | + /** |
|
79 | + * Adds a file to be sent with the request. |
|
80 | + * |
|
81 | + * @param string $varName The variable name to send the file in |
|
82 | + * @param string $fileName The name of the file as it should be received at the destination |
|
83 | + * @param string $content The raw content of the file |
|
84 | + * @param string $contentType The content type, use the constants to specify this |
|
85 | + * @param string $encoding The encoding of the file, use the constants to specify this |
|
86 | + */ |
|
87 | 87 | public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper_Boundaries |
88 | 88 | { |
89 | 89 | if(empty($contentType)) |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | return $this->addBoundary($boundary); |
108 | 108 | } |
109 | 109 | |
110 | - /** |
|
111 | - * Adds arbitrary content. |
|
112 | - * |
|
113 | - * @param string $varName |
|
114 | - * @param string $content |
|
115 | - * @param string $contentType |
|
116 | - */ |
|
110 | + /** |
|
111 | + * Adds arbitrary content. |
|
112 | + * |
|
113 | + * @param string $varName |
|
114 | + * @param string $content |
|
115 | + * @param string $contentType |
|
116 | + */ |
|
117 | 117 | public function addContent(string $varName, string $content, string $contentType) : RequestHelper_Boundaries |
118 | 118 | { |
119 | 119 | $content = ConvertHelper::string2utf8($content); |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | return $this->addBoundary($boundary); |
128 | 128 | } |
129 | 129 | |
130 | - /** |
|
131 | - * Adds a variable to be sent with the request. If it |
|
132 | - * already exists, its value is overwritten. |
|
133 | - * |
|
134 | - * @param string $name |
|
135 | - * @param string $value |
|
136 | - */ |
|
130 | + /** |
|
131 | + * Adds a variable to be sent with the request. If it |
|
132 | + * already exists, its value is overwritten. |
|
133 | + * |
|
134 | + * @param string $name |
|
135 | + * @param string $value |
|
136 | + */ |
|
137 | 137 | public function addVariable(string $name, string $value) : RequestHelper_Boundaries |
138 | 138 | { |
139 | 139 | $boundary = $this->createBoundary($value) |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | return $this; |
150 | 150 | } |
151 | 151 | |
152 | - /** |
|
153 | - * Renders the response body with all mime boundaries. |
|
154 | - * |
|
155 | - * @return string |
|
156 | - */ |
|
152 | + /** |
|
153 | + * Renders the response body with all mime boundaries. |
|
154 | + * |
|
155 | + * @return string |
|
156 | + */ |
|
157 | 157 | public function render() : string |
158 | 158 | { |
159 | 159 | if(empty($this->boundaries)) |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | |
32 | 32 | const BASE_2 = 1024; |
33 | 33 | |
34 | - /** |
|
35 | - * @var ConvertHelper_StorageSizeEnum_Size[] |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var ConvertHelper_StorageSizeEnum_Size[] |
|
36 | + */ |
|
37 | 37 | protected static $sizes = array(); |
38 | 38 | |
39 | - /** |
|
40 | - * Initializes the supported unit notations, and |
|
41 | - * how they are supposed to be calculated. |
|
42 | - * |
|
43 | - * @see ConvertHelper_SizeNotation::parseSize() |
|
44 | - */ |
|
39 | + /** |
|
40 | + * Initializes the supported unit notations, and |
|
41 | + * how they are supposed to be calculated. |
|
42 | + * |
|
43 | + * @see ConvertHelper_SizeNotation::parseSize() |
|
44 | + */ |
|
45 | 45 | protected static function init() : void |
46 | 46 | { |
47 | 47 | if(!empty(self::$sizes)) { |
@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - /** |
|
72 | - * Called whenever the application locale is changed, |
|
73 | - * to reset the size definitions so the labels get |
|
74 | - * translated to the new locale. |
|
75 | - */ |
|
71 | + /** |
|
72 | + * Called whenever the application locale is changed, |
|
73 | + * to reset the size definitions so the labels get |
|
74 | + * translated to the new locale. |
|
75 | + */ |
|
76 | 76 | public static function handle_localeChanged() : void |
77 | 77 | { |
78 | 78 | self::$sizes = array(); |
79 | 79 | } |
80 | 80 | |
81 | - /** |
|
82 | - * Adds a storage size to the internal collection. |
|
83 | - * |
|
84 | - * @param string $name The lowercase size name, e.g. "kb", "mib" |
|
85 | - * @param int $base This defines how many bytes there are in a kilobyte, to differentiate with the two common way to calculate sizes: base 10 or base 2. See the Wikipedia link for more details. |
|
86 | - * @param int $exponent The multiplier of the base to get the byte value |
|
87 | - * @param string $suffix The localized short suffix, e.g. "KB", "MiB" |
|
88 | - * @param string $singular The localized singular label of the size, e.g. "Kilobyte". |
|
89 | - * @param string $plural The localized plural label of the size, e.g. "Kilobytes". |
|
90 | - * |
|
91 | - * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions |
|
92 | - */ |
|
81 | + /** |
|
82 | + * Adds a storage size to the internal collection. |
|
83 | + * |
|
84 | + * @param string $name The lowercase size name, e.g. "kb", "mib" |
|
85 | + * @param int $base This defines how many bytes there are in a kilobyte, to differentiate with the two common way to calculate sizes: base 10 or base 2. See the Wikipedia link for more details. |
|
86 | + * @param int $exponent The multiplier of the base to get the byte value |
|
87 | + * @param string $suffix The localized short suffix, e.g. "KB", "MiB" |
|
88 | + * @param string $singular The localized singular label of the size, e.g. "Kilobyte". |
|
89 | + * @param string $plural The localized plural label of the size, e.g. "Kilobytes". |
|
90 | + * |
|
91 | + * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions |
|
92 | + */ |
|
93 | 93 | protected static function addSize(string $name, int $base, int $exponent, string $suffix, string $singular, string $plural) : void |
94 | 94 | { |
95 | 95 | self::$sizes[$name] = new ConvertHelper_StorageSizeEnum_Size( |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | - /** |
|
106 | - * Retrieves all known sizes. |
|
107 | - * |
|
108 | - * @return \AppUtils\ConvertHelper_StorageSizeEnum_Size[] |
|
109 | - */ |
|
105 | + /** |
|
106 | + * Retrieves all known sizes. |
|
107 | + * |
|
108 | + * @return \AppUtils\ConvertHelper_StorageSizeEnum_Size[] |
|
109 | + */ |
|
110 | 110 | public static function getSizes() : array |
111 | 111 | { |
112 | 112 | self::init(); |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | return self::$sizes; |
115 | 115 | } |
116 | 116 | |
117 | - /** |
|
118 | - * Retrieves a size definition instance by its name. |
|
119 | - * |
|
120 | - * @param string $name Case insensitive. For example "kb", "MiB"... |
|
121 | - * @throws ConvertHelper_Exception |
|
122 | - * @return ConvertHelper_StorageSizeEnum_Size |
|
123 | - * |
|
124 | - * @see ConvertHelper_StorageSizeEnum::ERROR_UNKNOWN_UNIT_NAME |
|
125 | - */ |
|
117 | + /** |
|
118 | + * Retrieves a size definition instance by its name. |
|
119 | + * |
|
120 | + * @param string $name Case insensitive. For example "kb", "MiB"... |
|
121 | + * @throws ConvertHelper_Exception |
|
122 | + * @return ConvertHelper_StorageSizeEnum_Size |
|
123 | + * |
|
124 | + * @see ConvertHelper_StorageSizeEnum::ERROR_UNKNOWN_UNIT_NAME |
|
125 | + */ |
|
126 | 126 | public static function getSizeByName(string $name) : ConvertHelper_StorageSizeEnum_Size |
127 | 127 | { |
128 | 128 | self::init(); |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
147 | - /** |
|
148 | - * Retrieves a list of all size names, e.g. "mb", "kib" (lowercase). |
|
149 | - * @return array |
|
150 | - */ |
|
147 | + /** |
|
148 | + * Retrieves a list of all size names, e.g. "mb", "kib" (lowercase). |
|
149 | + * @return array |
|
150 | + */ |
|
151 | 151 | public static function getSizeNames() : array |
152 | 152 | { |
153 | 153 | self::init(); |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | return array_keys(self::$sizes); |
156 | 156 | } |
157 | 157 | |
158 | - /** |
|
159 | - * Retrieves all available storage sizes for the specified |
|
160 | - * base value. |
|
161 | - * |
|
162 | - * @param int $base |
|
163 | - * @return \AppUtils\ConvertHelper_StorageSizeEnum_Size[] |
|
164 | - * |
|
165 | - * @see ConvertHelper_StorageSizeEnum::BASE_10 |
|
166 | - * @see ConvertHelper_StorageSizeEnum::BASE_2 |
|
167 | - */ |
|
158 | + /** |
|
159 | + * Retrieves all available storage sizes for the specified |
|
160 | + * base value. |
|
161 | + * |
|
162 | + * @param int $base |
|
163 | + * @return \AppUtils\ConvertHelper_StorageSizeEnum_Size[] |
|
164 | + * |
|
165 | + * @see ConvertHelper_StorageSizeEnum::BASE_10 |
|
166 | + * @see ConvertHelper_StorageSizeEnum::BASE_2 |
|
167 | + */ |
|
168 | 168 | public static function getSizesByBase(int $base) : array |
169 | 169 | { |
170 | 170 | self::init(); |
@@ -23,37 +23,37 @@ |
||
23 | 23 | { |
24 | 24 | const ERROR_NOT_LOADED_YET = 56501; |
25 | 25 | |
26 | - /** |
|
27 | - * @var \SimpleXMLElement|NULL |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var \SimpleXMLElement|NULL |
|
28 | + */ |
|
29 | 29 | private $element = null; |
30 | 30 | |
31 | - /** |
|
32 | - * @var XMLHelper_SimpleXML_Error[] |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var XMLHelper_SimpleXML_Error[] |
|
33 | + */ |
|
34 | 34 | private $errors = array(); |
35 | 35 | |
36 | - /** |
|
37 | - * Creates a simplexml instance from an XML string. |
|
38 | - * |
|
39 | - * NOTE: returns false in case of a fatal error. |
|
40 | - * |
|
41 | - * @param string $string |
|
42 | - * @return \SimpleXMLElement|NULL |
|
43 | - */ |
|
36 | + /** |
|
37 | + * Creates a simplexml instance from an XML string. |
|
38 | + * |
|
39 | + * NOTE: returns false in case of a fatal error. |
|
40 | + * |
|
41 | + * @param string $string |
|
42 | + * @return \SimpleXMLElement|NULL |
|
43 | + */ |
|
44 | 44 | public function loadString(string $string) : ?\SimpleXMLElement |
45 | 45 | { |
46 | 46 | return $this->load('string', $string); |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * Creates a simplexml instance from an XML file. |
|
51 | - * |
|
52 | - * NOTE: returns false in case of a fatal error. |
|
53 | - * |
|
54 | - * @param string $file |
|
55 | - * @return \SimpleXMLElement|NULL |
|
56 | - */ |
|
49 | + /** |
|
50 | + * Creates a simplexml instance from an XML file. |
|
51 | + * |
|
52 | + * NOTE: returns false in case of a fatal error. |
|
53 | + * |
|
54 | + * @param string $file |
|
55 | + * @return \SimpleXMLElement|NULL |
|
56 | + */ |
|
57 | 57 | public function loadFile(string $file) : ?\SimpleXMLElement |
58 | 58 | { |
59 | 59 | return $this->load('file', $file); |
@@ -24,9 +24,9 @@ |
||
24 | 24 | const ERROR_CANNOT_UNSERIALIZE_ERROR_DATA = 57201; |
25 | 25 | const ERROR_ERROR_DATA_KEY_MISSING = 57202; |
26 | 26 | |
27 | - /** |
|
28 | - * @var \LibXMLError |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var \LibXMLError |
|
29 | + */ |
|
30 | 30 | private $error; |
31 | 31 | |
32 | 32 | private static $requiredKeys = array( |
@@ -36,19 +36,19 @@ discard block |
||
36 | 36 | { |
37 | 37 | const ERROR_STRING_ALREADY_HAS_BODY_TAG = 57001; |
38 | 38 | |
39 | - /** |
|
40 | - * @var \DOMElement |
|
41 | - */ |
|
39 | + /** |
|
40 | + * @var \DOMElement |
|
41 | + */ |
|
42 | 42 | private $bodyNode; |
43 | 43 | |
44 | - /** |
|
45 | - * @var XMLHelper_DOMErrors |
|
46 | - */ |
|
44 | + /** |
|
45 | + * @var XMLHelper_DOMErrors |
|
46 | + */ |
|
47 | 47 | private $errors; |
48 | 48 | |
49 | - /** |
|
50 | - * @var string |
|
51 | - */ |
|
49 | + /** |
|
50 | + * @var string |
|
51 | + */ |
|
52 | 52 | private static $htmlTemplate = |
53 | 53 | '<!DOCTYPE html>'. |
54 | 54 | '<html>'. |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | '</body>'. |
61 | 61 | '</html>'; |
62 | 62 | |
63 | - /** |
|
64 | - * @var \DOMDocument |
|
65 | - */ |
|
63 | + /** |
|
64 | + * @var \DOMDocument |
|
65 | + */ |
|
66 | 66 | private $dom; |
67 | 67 | |
68 | 68 | private function __construct(string $html) |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | $this->load($html); |
71 | 71 | } |
72 | 72 | |
73 | - /** |
|
74 | - * Creates an HTML loader from an HTML fragment (without |
|
75 | - * doctype, head and body elements). |
|
76 | - * |
|
77 | - * @param string $fragment |
|
78 | - * @return XMLHelper_HTMLLoader |
|
79 | - */ |
|
73 | + /** |
|
74 | + * Creates an HTML loader from an HTML fragment (without |
|
75 | + * doctype, head and body elements). |
|
76 | + * |
|
77 | + * @param string $fragment |
|
78 | + * @return XMLHelper_HTMLLoader |
|
79 | + */ |
|
80 | 80 | public static function loadFragment(string $fragment) : XMLHelper_HTMLLoader |
81 | 81 | { |
82 | 82 | self::checkFragment($fragment); |
@@ -87,24 +87,24 @@ discard block |
||
87 | 87 | return new XMLHelper_HTMLLoader($pseudoHTML); |
88 | 88 | } |
89 | 89 | |
90 | - /** |
|
91 | - * Creates an HTML loader from a full HTML document (including |
|
92 | - * doctype, head and body elements). |
|
93 | - * |
|
94 | - * @param string $html |
|
95 | - * @return XMLHelper_HTMLLoader |
|
96 | - */ |
|
90 | + /** |
|
91 | + * Creates an HTML loader from a full HTML document (including |
|
92 | + * doctype, head and body elements). |
|
93 | + * |
|
94 | + * @param string $html |
|
95 | + * @return XMLHelper_HTMLLoader |
|
96 | + */ |
|
97 | 97 | public static function loadHTML(string $html) : XMLHelper_HTMLLoader |
98 | 98 | { |
99 | 99 | return new XMLHelper_HTMLLoader($html); |
100 | 100 | } |
101 | 101 | |
102 | - /** |
|
103 | - * Verifies that the fragment does not already contain a body element or doctype. |
|
104 | - * |
|
105 | - * @param string $fragment |
|
106 | - * @throws XMLHelper_Exception |
|
107 | - */ |
|
102 | + /** |
|
103 | + * Verifies that the fragment does not already contain a body element or doctype. |
|
104 | + * |
|
105 | + * @param string $fragment |
|
106 | + * @throws XMLHelper_Exception |
|
107 | + */ |
|
108 | 108 | private static function checkFragment(string $fragment) : void |
109 | 109 | { |
110 | 110 | if(!stristr($fragment, '<body') && !stristr($fragment, 'doctype')) |
@@ -142,65 +142,65 @@ discard block |
||
142 | 142 | return $this->bodyNode; |
143 | 143 | } |
144 | 144 | |
145 | - /** |
|
146 | - * Retrieves the document's `<body>` tag node. |
|
147 | - * |
|
148 | - * @return \DOMDocument |
|
149 | - */ |
|
145 | + /** |
|
146 | + * Retrieves the document's `<body>` tag node. |
|
147 | + * |
|
148 | + * @return \DOMDocument |
|
149 | + */ |
|
150 | 150 | public function getDOM() : \DOMDocument |
151 | 151 | { |
152 | 152 | return $this->dom; |
153 | 153 | } |
154 | 154 | |
155 | - /** |
|
156 | - * Retrieves all nodes from the HTML fragment (= child nodes |
|
157 | - * of the `<body>` element). |
|
158 | - * |
|
159 | - * @return \DOMNodeList |
|
160 | - */ |
|
155 | + /** |
|
156 | + * Retrieves all nodes from the HTML fragment (= child nodes |
|
157 | + * of the `<body>` element). |
|
158 | + * |
|
159 | + * @return \DOMNodeList |
|
160 | + */ |
|
161 | 161 | public function getFragmentNodes() : \DOMNodeList |
162 | 162 | { |
163 | 163 | return $this->bodyNode->childNodes; |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
167 | - * Retrieves the LibXML HTML parsing errors collection, which |
|
168 | - * can be used to review any errors that occurred while loading |
|
169 | - * the HTML document. |
|
170 | - * |
|
171 | - * @return XMLHelper_DOMErrors |
|
172 | - */ |
|
166 | + /** |
|
167 | + * Retrieves the LibXML HTML parsing errors collection, which |
|
168 | + * can be used to review any errors that occurred while loading |
|
169 | + * the HTML document. |
|
170 | + * |
|
171 | + * @return XMLHelper_DOMErrors |
|
172 | + */ |
|
173 | 173 | public function getErrors() : XMLHelper_DOMErrors |
174 | 174 | { |
175 | 175 | return $this->errors; |
176 | 176 | } |
177 | 177 | |
178 | - /** |
|
179 | - * Returns a valid HTML string. |
|
180 | - * |
|
181 | - * @return string |
|
182 | - */ |
|
178 | + /** |
|
179 | + * Returns a valid HTML string. |
|
180 | + * |
|
181 | + * @return string |
|
182 | + */ |
|
183 | 183 | public function toHTML() : string |
184 | 184 | { |
185 | 185 | return $this->dom->saveHTML(); |
186 | 186 | } |
187 | 187 | |
188 | - /** |
|
189 | - * Returns a valid XML string. |
|
190 | - * |
|
191 | - * @return string |
|
192 | - */ |
|
188 | + /** |
|
189 | + * Returns a valid XML string. |
|
190 | + * |
|
191 | + * @return string |
|
192 | + */ |
|
193 | 193 | public function toXML() : string |
194 | 194 | { |
195 | 195 | return $this->dom->saveXML(); |
196 | 196 | } |
197 | 197 | |
198 | - /** |
|
199 | - * Converts the HTML fragment to valid XML (= all |
|
200 | - * child nodes of the `<body>` element). |
|
201 | - * |
|
202 | - * @return string |
|
203 | - */ |
|
198 | + /** |
|
199 | + * Converts the HTML fragment to valid XML (= all |
|
200 | + * child nodes of the `<body>` element). |
|
201 | + * |
|
202 | + * @return string |
|
203 | + */ |
|
204 | 204 | public function fragmentToXML() : string |
205 | 205 | { |
206 | 206 | $nodes = $this->getFragmentNodes(); |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | { |
24 | 24 | const SERIALIZE_SEPARATOR = '__SERSEP__'; |
25 | 25 | |
26 | - /** |
|
27 | - * @var XMLHelper_DOMErrors_Error[] |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var XMLHelper_DOMErrors_Error[] |
|
28 | + */ |
|
29 | 29 | private $errors; |
30 | 30 | |
31 | - /** |
|
32 | - * @param \LibXMLError[]|XMLHelper_DOMErrors_Error[] $libxmlErrors |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @param \LibXMLError[]|XMLHelper_DOMErrors_Error[] $libxmlErrors |
|
33 | + */ |
|
34 | 34 | public function __construct(array $libxmlErrors) |
35 | 35 | { |
36 | 36 | foreach($libxmlErrors as $error) |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | return $this->errors; |
57 | 57 | } |
58 | 58 | |
59 | - /** |
|
60 | - * Retrieves all warnings, if any. |
|
61 | - * |
|
62 | - * @return XMLHelper_DOMErrors_Error[] |
|
63 | - */ |
|
59 | + /** |
|
60 | + * Retrieves all warnings, if any. |
|
61 | + * |
|
62 | + * @return XMLHelper_DOMErrors_Error[] |
|
63 | + */ |
|
64 | 64 | public function getWarnings() |
65 | 65 | { |
66 | 66 | return $this->getByLevel(LIBXML_ERR_WARNING); |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | |
110 | - /** |
|
111 | - * Retrieves all errors by the specified libxml error level. |
|
112 | - * |
|
113 | - * @param int $level |
|
114 | - * @return \AppUtils\XMLHelper_DOMErrors_Error[] |
|
115 | - */ |
|
110 | + /** |
|
111 | + * Retrieves all errors by the specified libxml error level. |
|
112 | + * |
|
113 | + * @param int $level |
|
114 | + * @return \AppUtils\XMLHelper_DOMErrors_Error[] |
|
115 | + */ |
|
116 | 116 | public function getByLevel(int $level) |
117 | 117 | { |
118 | 118 | $result = array(); |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | return $result; |
129 | 129 | } |
130 | 130 | |
131 | - /** |
|
132 | - * Retrieves all errors by the specified libxml error code. |
|
133 | - * |
|
134 | - * @param int $code |
|
135 | - * @return \AppUtils\XMLHelper_DOMErrors_Error[] |
|
136 | - */ |
|
131 | + /** |
|
132 | + * Retrieves all errors by the specified libxml error code. |
|
133 | + * |
|
134 | + * @param int $code |
|
135 | + * @return \AppUtils\XMLHelper_DOMErrors_Error[] |
|
136 | + */ |
|
137 | 137 | public function getByCode(int $code) |
138 | 138 | { |
139 | 139 | $result = array(); |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | return $result; |
150 | 150 | } |
151 | 151 | |
152 | - /** |
|
153 | - * Checks whether there are errors matching the libxml error level. |
|
154 | - * |
|
155 | - * @param int $level |
|
156 | - * @return bool |
|
157 | - */ |
|
152 | + /** |
|
153 | + * Checks whether there are errors matching the libxml error level. |
|
154 | + * |
|
155 | + * @param int $level |
|
156 | + * @return bool |
|
157 | + */ |
|
158 | 158 | public function hasErrorsByLevel(int $level) : bool |
159 | 159 | { |
160 | 160 | foreach($this->errors as $error) |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | return false; |
169 | 169 | } |
170 | 170 | |
171 | - /** |
|
172 | - * Checks whether there are any errors matching the libxml error code. |
|
173 | - * |
|
174 | - * @param int $code |
|
175 | - * @return bool |
|
176 | - */ |
|
171 | + /** |
|
172 | + * Checks whether there are any errors matching the libxml error code. |
|
173 | + * |
|
174 | + * @param int $code |
|
175 | + * @return bool |
|
176 | + */ |
|
177 | 177 | public function hasErrorsByCode(int $code) : bool |
178 | 178 | { |
179 | 179 | foreach($this->errors as $error) |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | return $result; |
200 | 200 | } |
201 | 201 | |
202 | - /** |
|
203 | - * Serializes the errors collection, so it can be stored and |
|
204 | - * restored as needed, using the `fromSerialized()` method. |
|
205 | - * |
|
206 | - * @return string |
|
207 | - * @see XMLHelper_DOMErrors::fromSerialized() |
|
208 | - */ |
|
202 | + /** |
|
203 | + * Serializes the errors collection, so it can be stored and |
|
204 | + * restored as needed, using the `fromSerialized()` method. |
|
205 | + * |
|
206 | + * @return string |
|
207 | + * @see XMLHelper_DOMErrors::fromSerialized() |
|
208 | + */ |
|
209 | 209 | public function serialize() : string |
210 | 210 | { |
211 | 211 | $data = array(); |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | return implode(self::SERIALIZE_SEPARATOR, $data); |
219 | 219 | } |
220 | 220 | |
221 | - /** |
|
222 | - * Restores the errors collection from a previously serialized |
|
223 | - * collection, using `serialize()`. |
|
224 | - * |
|
225 | - * @param string $serialized |
|
226 | - * @return XMLHelper_DOMErrors |
|
227 | - * @see XMLHelper_DOMErrors::serialize() |
|
228 | - */ |
|
221 | + /** |
|
222 | + * Restores the errors collection from a previously serialized |
|
223 | + * collection, using `serialize()`. |
|
224 | + * |
|
225 | + * @param string $serialized |
|
226 | + * @return XMLHelper_DOMErrors |
|
227 | + * @see XMLHelper_DOMErrors::serialize() |
|
228 | + */ |
|
229 | 229 | public static function fromSerialized(string $serialized) : XMLHelper_DOMErrors |
230 | 230 | { |
231 | 231 | $parts = explode(self::SERIALIZE_SEPARATOR, $serialized); |