@@ -30,17 +30,17 @@ discard block |
||
30 | 30 | public const BASE_10 = 1000; |
31 | 31 | public const BASE_2 = 1024; |
32 | 32 | |
33 | - /** |
|
34 | - * @var array<string,ConvertHelper_StorageSizeEnum_Size> |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var array<string,ConvertHelper_StorageSizeEnum_Size> |
|
35 | + */ |
|
36 | 36 | protected static $sizes = array(); |
37 | 37 | |
38 | - /** |
|
39 | - * Initializes the supported unit notations, and |
|
40 | - * how they are supposed to be calculated. |
|
41 | - * |
|
42 | - * @see ConvertHelper_SizeNotation::parseSize() |
|
43 | - */ |
|
38 | + /** |
|
39 | + * Initializes the supported unit notations, and |
|
40 | + * how they are supposed to be calculated. |
|
41 | + * |
|
42 | + * @see ConvertHelper_SizeNotation::parseSize() |
|
43 | + */ |
|
44 | 44 | protected static function init() : void |
45 | 45 | { |
46 | 46 | if(!empty(self::$sizes)) { |
@@ -67,28 +67,28 @@ discard block |
||
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - /** |
|
71 | - * Called whenever the application locale is changed, |
|
72 | - * to reset the size definitions so the labels get |
|
73 | - * translated to the new locale. |
|
74 | - */ |
|
70 | + /** |
|
71 | + * Called whenever the application locale is changed, |
|
72 | + * to reset the size definitions so the labels get |
|
73 | + * translated to the new locale. |
|
74 | + */ |
|
75 | 75 | public static function handle_localeChanged() : void |
76 | 76 | { |
77 | 77 | self::$sizes = array(); |
78 | 78 | } |
79 | 79 | |
80 | - /** |
|
81 | - * Adds a storage size to the internal collection. |
|
82 | - * |
|
83 | - * @param string $name The lowercase size name, e.g. "kb", "mib" |
|
84 | - * @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. |
|
85 | - * @param int $exponent The multiplier of the base to get the byte value |
|
86 | - * @param string $suffix The localized short suffix, e.g. "KB", "MiB" |
|
87 | - * @param string $singular The localized singular label of the size, e.g. "Kilobyte". |
|
88 | - * @param string $plural The localized plural label of the size, e.g. "Kilobytes". |
|
89 | - * |
|
90 | - * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions |
|
91 | - */ |
|
80 | + /** |
|
81 | + * Adds a storage size to the internal collection. |
|
82 | + * |
|
83 | + * @param string $name The lowercase size name, e.g. "kb", "mib" |
|
84 | + * @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. |
|
85 | + * @param int $exponent The multiplier of the base to get the byte value |
|
86 | + * @param string $suffix The localized short suffix, e.g. "KB", "MiB" |
|
87 | + * @param string $singular The localized singular label of the size, e.g. "Kilobyte". |
|
88 | + * @param string $plural The localized plural label of the size, e.g. "Kilobytes". |
|
89 | + * |
|
90 | + * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions |
|
91 | + */ |
|
92 | 92 | protected static function addSize(string $name, int $base, int $exponent, string $suffix, string $singular, string $plural) : void |
93 | 93 | { |
94 | 94 | self::$sizes[$name] = new ConvertHelper_StorageSizeEnum_Size( |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | ); |
102 | 102 | } |
103 | 103 | |
104 | - /** |
|
105 | - * Retrieves all known sizes. |
|
106 | - * |
|
107 | - * @return ConvertHelper_StorageSizeEnum_Size[] |
|
108 | - */ |
|
104 | + /** |
|
105 | + * Retrieves all known sizes. |
|
106 | + * |
|
107 | + * @return ConvertHelper_StorageSizeEnum_Size[] |
|
108 | + */ |
|
109 | 109 | public static function getSizes() : array |
110 | 110 | { |
111 | 111 | self::init(); |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | return array_values(self::$sizes); |
114 | 114 | } |
115 | 115 | |
116 | - /** |
|
117 | - * Retrieves a size definition instance by its name. |
|
118 | - * |
|
119 | - * @param string $name Case-insensitive. For example "kb", "MiB"... |
|
120 | - * @throws ConvertHelper_Exception |
|
121 | - * @return ConvertHelper_StorageSizeEnum_Size |
|
122 | - * |
|
123 | - * @see ConvertHelper_StorageSizeEnum::ERROR_UNKNOWN_UNIT_NAME |
|
124 | - */ |
|
116 | + /** |
|
117 | + * Retrieves a size definition instance by its name. |
|
118 | + * |
|
119 | + * @param string $name Case-insensitive. For example "kb", "MiB"... |
|
120 | + * @throws ConvertHelper_Exception |
|
121 | + * @return ConvertHelper_StorageSizeEnum_Size |
|
122 | + * |
|
123 | + * @see ConvertHelper_StorageSizeEnum::ERROR_UNKNOWN_UNIT_NAME |
|
124 | + */ |
|
125 | 125 | public static function getSizeByName(string $name) : ConvertHelper_StorageSizeEnum_Size |
126 | 126 | { |
127 | 127 | self::init(); |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | ); |
144 | 144 | } |
145 | 145 | |
146 | - /** |
|
147 | - * Retrieves a list of all size names, e.g. "mb", "kib" (lowercase). |
|
148 | - * @return string[] |
|
149 | - */ |
|
146 | + /** |
|
147 | + * Retrieves a list of all size names, e.g. "mb", "kib" (lowercase). |
|
148 | + * @return string[] |
|
149 | + */ |
|
150 | 150 | public static function getSizeNames() : array |
151 | 151 | { |
152 | 152 | self::init(); |
@@ -154,16 +154,16 @@ discard block |
||
154 | 154 | return array_keys(self::$sizes); |
155 | 155 | } |
156 | 156 | |
157 | - /** |
|
158 | - * Retrieves all available storage sizes for the specified |
|
159 | - * base value. |
|
160 | - * |
|
161 | - * @param int $base |
|
162 | - * @return ConvertHelper_StorageSizeEnum_Size[] |
|
163 | - * |
|
164 | - * @see ConvertHelper_StorageSizeEnum::BASE_10 |
|
165 | - * @see ConvertHelper_StorageSizeEnum::BASE_2 |
|
166 | - */ |
|
157 | + /** |
|
158 | + * Retrieves all available storage sizes for the specified |
|
159 | + * base value. |
|
160 | + * |
|
161 | + * @param int $base |
|
162 | + * @return ConvertHelper_StorageSizeEnum_Size[] |
|
163 | + * |
|
164 | + * @see ConvertHelper_StorageSizeEnum::BASE_10 |
|
165 | + * @see ConvertHelper_StorageSizeEnum::BASE_2 |
|
166 | + */ |
|
167 | 167 | public static function getSizesByBase(int $base) : array |
168 | 168 | { |
169 | 169 | self::init(); |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | { |
23 | 23 | public 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)) |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | */ |
27 | 27 | trait Traits_Optionable |
28 | 28 | { |
29 | - /** |
|
30 | - * @var array|NULL |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var array|NULL |
|
31 | + */ |
|
32 | 32 | protected $options = null; |
33 | 33 | |
34 | 34 | /** |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | return $this; |
50 | 50 | } |
51 | 51 | |
52 | - /** |
|
53 | - * Sets a collection of options at once, from an |
|
54 | - * associative array. |
|
55 | - * |
|
56 | - * @param array<string,mixed> $options |
|
57 | - * @return $this |
|
58 | - */ |
|
52 | + /** |
|
53 | + * Sets a collection of options at once, from an |
|
54 | + * associative array. |
|
55 | + * |
|
56 | + * @param array<string,mixed> $options |
|
57 | + * @return $this |
|
58 | + */ |
|
59 | 59 | public function setOptions(array $options) |
60 | 60 | { |
61 | 61 | foreach($options as $name => $value) { |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | return $this; |
66 | 66 | } |
67 | 67 | |
68 | - /** |
|
69 | - * Retrieves an option's value. |
|
70 | - * |
|
71 | - * NOTE: Use the specialized type getters to ensure an option |
|
72 | - * contains the expected type (for ex. getArrayOption()). |
|
73 | - * |
|
74 | - * @param string $name |
|
75 | - * @param mixed $default The default value to return if the option does not exist. |
|
76 | - * @return mixed |
|
77 | - */ |
|
68 | + /** |
|
69 | + * Retrieves an option's value. |
|
70 | + * |
|
71 | + * NOTE: Use the specialized type getters to ensure an option |
|
72 | + * contains the expected type (for ex. getArrayOption()). |
|
73 | + * |
|
74 | + * @param string $name |
|
75 | + * @param mixed $default The default value to return if the option does not exist. |
|
76 | + * @return mixed |
|
77 | + */ |
|
78 | 78 | public function getOption(string $name, $default=null) |
79 | 79 | { |
80 | 80 | if(!isset($this->options)) { |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | return $default; |
89 | 89 | } |
90 | 90 | |
91 | - /** |
|
92 | - * Enforces that the option value is a string. Numbers are converted |
|
93 | - * to string, strings are passed through, and all other types will |
|
94 | - * return the default value. The default value is also returned if |
|
95 | - * the string is empty. |
|
96 | - * |
|
97 | - * @param string $name |
|
98 | - * @param string $default Used if the option does not exist, is invalid, or empty. |
|
99 | - * @return string |
|
100 | - */ |
|
91 | + /** |
|
92 | + * Enforces that the option value is a string. Numbers are converted |
|
93 | + * to string, strings are passed through, and all other types will |
|
94 | + * return the default value. The default value is also returned if |
|
95 | + * the string is empty. |
|
96 | + * |
|
97 | + * @param string $name |
|
98 | + * @param string $default Used if the option does not exist, is invalid, or empty. |
|
99 | + * @return string |
|
100 | + */ |
|
101 | 101 | public function getStringOption(string $name, string $default='') : string |
102 | 102 | { |
103 | 103 | $value = $this->getOption($name, false); |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | return $default; |
129 | 129 | } |
130 | 130 | |
131 | - /** |
|
132 | - * Treats the option value as an integer value: will return |
|
133 | - * valid integer values (also from integer strings), or the |
|
134 | - * default value otherwise. |
|
135 | - * |
|
136 | - * @param string $name |
|
137 | - * @param int $default |
|
138 | - * @return int |
|
139 | - */ |
|
131 | + /** |
|
132 | + * Treats the option value as an integer value: will return |
|
133 | + * valid integer values (also from integer strings), or the |
|
134 | + * default value otherwise. |
|
135 | + * |
|
136 | + * @param string $name |
|
137 | + * @param int $default |
|
138 | + * @return int |
|
139 | + */ |
|
140 | 140 | public function getIntOption(string $name, int $default=0) : int |
141 | 141 | { |
142 | 142 | $value = $this->getOption($name); |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | return $default; |
148 | 148 | } |
149 | 149 | |
150 | - /** |
|
151 | - * Treats an option as an array, and returns its value |
|
152 | - * only if it contains an array - otherwise, an empty |
|
153 | - * array is returned. |
|
154 | - * |
|
155 | - * @param string $name |
|
156 | - * @return array |
|
157 | - */ |
|
150 | + /** |
|
151 | + * Treats an option as an array, and returns its value |
|
152 | + * only if it contains an array - otherwise, an empty |
|
153 | + * array is returned. |
|
154 | + * |
|
155 | + * @param string $name |
|
156 | + * @return array |
|
157 | + */ |
|
158 | 158 | public function getArrayOption(string $name) : array |
159 | 159 | { |
160 | 160 | $val = $this->getOption($name); |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | return array(); |
166 | 166 | } |
167 | 167 | |
168 | - /** |
|
169 | - * Checks whether the specified option exists - even |
|
170 | - * if it has a NULL value. |
|
171 | - * |
|
172 | - * @param string $name |
|
173 | - * @return bool |
|
174 | - */ |
|
168 | + /** |
|
169 | + * Checks whether the specified option exists - even |
|
170 | + * if it has a NULL value. |
|
171 | + * |
|
172 | + * @param string $name |
|
173 | + * @return bool |
|
174 | + */ |
|
175 | 175 | public function hasOption(string $name) : bool |
176 | 176 | { |
177 | 177 | if(!isset($this->options)) { |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | return array_key_exists($name, $this->options); |
182 | 182 | } |
183 | 183 | |
184 | - /** |
|
185 | - * Returns all options in one associative array. |
|
186 | - * |
|
187 | - * @return array<string,mixed> |
|
188 | - */ |
|
184 | + /** |
|
185 | + * Returns all options in one associative array. |
|
186 | + * |
|
187 | + * @return array<string,mixed> |
|
188 | + */ |
|
189 | 189 | public function getOptions() : array |
190 | 190 | { |
191 | 191 | if(!isset($this->options)) { |
@@ -195,23 +195,23 @@ discard block |
||
195 | 195 | return $this->options; |
196 | 196 | } |
197 | 197 | |
198 | - /** |
|
199 | - * Checks whether the option's value is the one specified. |
|
200 | - * |
|
201 | - * @param string $name |
|
202 | - * @param mixed $value |
|
203 | - * @return bool |
|
204 | - */ |
|
198 | + /** |
|
199 | + * Checks whether the option's value is the one specified. |
|
200 | + * |
|
201 | + * @param string $name |
|
202 | + * @param mixed $value |
|
203 | + * @return bool |
|
204 | + */ |
|
205 | 205 | public function isOption(string $name, $value) : bool |
206 | 206 | { |
207 | 207 | return $this->getOption($name) === $value; |
208 | 208 | } |
209 | 209 | |
210 | - /** |
|
211 | - * Retrieves the default available options as an |
|
212 | - * associative array with option name => value pairs. |
|
213 | - * |
|
214 | - * @return array<string,mixed> |
|
215 | - */ |
|
210 | + /** |
|
211 | + * Retrieves the default available options as an |
|
212 | + * associative array with option name => value pairs. |
|
213 | + * |
|
214 | + * @return array<string,mixed> |
|
215 | + */ |
|
216 | 216 | abstract public function getDefaultOptions() : array; |
217 | 217 | } |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | */ |
26 | 26 | trait Traits_Classable |
27 | 27 | { |
28 | - /** |
|
29 | - * @var string[] |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var string[] |
|
30 | + */ |
|
31 | 31 | protected $classes = array(); |
32 | 32 | |
33 | 33 | public function hasClasses() : bool |
@@ -70,30 +70,30 @@ discard block |
||
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | - /** |
|
74 | - * Retrieves a list of all classes, if any. |
|
75 | - * |
|
76 | - * @return string[] |
|
77 | - */ |
|
73 | + /** |
|
74 | + * Retrieves a list of all classes, if any. |
|
75 | + * |
|
76 | + * @return string[] |
|
77 | + */ |
|
78 | 78 | public function getClasses() : array |
79 | 79 | { |
80 | 80 | return $this->classes; |
81 | 81 | } |
82 | 82 | |
83 | - /** |
|
84 | - * Renders the class names list as space-separated string for use in an HTML tag. |
|
85 | - * |
|
86 | - * @return string |
|
87 | - */ |
|
83 | + /** |
|
84 | + * Renders the class names list as space-separated string for use in an HTML tag. |
|
85 | + * |
|
86 | + * @return string |
|
87 | + */ |
|
88 | 88 | public function classesToString() : string |
89 | 89 | { |
90 | 90 | return implode(' ', $this->classes); |
91 | 91 | } |
92 | 92 | |
93 | - /** |
|
94 | - * Renders the "class" attribute string for inserting into an HTML tag. |
|
95 | - * @return string |
|
96 | - */ |
|
93 | + /** |
|
94 | + * Renders the "class" attribute string for inserting into an HTML tag. |
|
95 | + * @return string |
|
96 | + */ |
|
97 | 97 | public function classesToAttribute() : string |
98 | 98 | { |
99 | 99 | if(!empty($this->classes)) |
@@ -26,48 +26,48 @@ discard block |
||
26 | 26 | */ |
27 | 27 | class JSHelper |
28 | 28 | { |
29 | - /** |
|
30 | - * Quote style using single quotes. |
|
31 | - * @var integer |
|
32 | - */ |
|
29 | + /** |
|
30 | + * Quote style using single quotes. |
|
31 | + * @var integer |
|
32 | + */ |
|
33 | 33 | public const QUOTE_STYLE_SINGLE = 1; |
34 | 34 | |
35 | - /** |
|
36 | - * Quote style using double quotes. |
|
37 | - * @var integer |
|
38 | - */ |
|
35 | + /** |
|
36 | + * Quote style using double quotes. |
|
37 | + * @var integer |
|
38 | + */ |
|
39 | 39 | public const QUOTE_STYLE_DOUBLE = 2; |
40 | 40 | |
41 | - /** |
|
42 | - * @var array |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var array |
|
43 | + */ |
|
44 | 44 | protected static $variableCache = array(); |
45 | 45 | |
46 | - /** |
|
47 | - * @var integer |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var integer |
|
48 | + */ |
|
49 | 49 | protected static $elementCounter = 0; |
50 | 50 | |
51 | - /** |
|
52 | - * @var string |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var string |
|
53 | + */ |
|
54 | 54 | protected static $idPrefix = 'E'; |
55 | 55 | |
56 | - /** |
|
57 | - * Builds a javascript statement. The first parameter is the |
|
58 | - * javascript function to call, any additional parameters are |
|
59 | - * used as arguments for the javascript function call. Variable |
|
60 | - * types are automagically converted to the javascript equivalents. |
|
61 | - * |
|
62 | - * Examples: |
|
63 | - * |
|
64 | - * // add an alert(); statement: |
|
65 | - * JSHelper::buildStatement('alert'); |
|
66 | - * |
|
67 | - * // add an alert('Alert text'); statement |
|
68 | - * JSHelper::buildStatement('alert', 'Alert text'); |
|
69 | - * |
|
70 | - */ |
|
56 | + /** |
|
57 | + * Builds a javascript statement. The first parameter is the |
|
58 | + * javascript function to call, any additional parameters are |
|
59 | + * used as arguments for the javascript function call. Variable |
|
60 | + * types are automagically converted to the javascript equivalents. |
|
61 | + * |
|
62 | + * Examples: |
|
63 | + * |
|
64 | + * // add an alert(); statement: |
|
65 | + * JSHelper::buildStatement('alert'); |
|
66 | + * |
|
67 | + * // add an alert('Alert text'); statement |
|
68 | + * JSHelper::buildStatement('alert', 'Alert text'); |
|
69 | + * |
|
70 | + */ |
|
71 | 71 | public static function buildStatement() : string |
72 | 72 | { |
73 | 73 | $args = func_get_args(); |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | return call_user_func_array(array(self::class, 'buildStatementQuoteStyle'), $args); |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * Like {@link JSHelper::buildStatement()}, but using single quotes |
|
80 | - * to make it possible to use the statement in an HTML tag attribute. |
|
81 | - * |
|
82 | - * @return string |
|
83 | - * @see JSHelper::buildStatement() |
|
84 | - */ |
|
78 | + /** |
|
79 | + * Like {@link JSHelper::buildStatement()}, but using single quotes |
|
80 | + * to make it possible to use the statement in an HTML tag attribute. |
|
81 | + * |
|
82 | + * @return string |
|
83 | + * @see JSHelper::buildStatement() |
|
84 | + */ |
|
85 | 85 | public static function buildStatementAttribute() : string |
86 | 86 | { |
87 | 87 | $args = func_get_args(); |
@@ -111,39 +111,39 @@ discard block |
||
111 | 111 | return $call . ');'; |
112 | 112 | } |
113 | 113 | |
114 | - /** |
|
115 | - * Builds a set variable statement. The variable value is |
|
116 | - * automatically converted to the javascript equivalent. |
|
117 | - * |
|
118 | - * Examples: |
|
119 | - * |
|
120 | - * // foo = 'bar'; |
|
121 | - * JSHelper::buildVariable('foo', 'bar'); |
|
122 | - * |
|
123 | - * // foo = 42; |
|
124 | - * JSHelper::buildVariable('foo', 42); |
|
125 | - * |
|
126 | - * // foo = true; |
|
127 | - * JSHelper::buildVariable('foo', true); |
|
128 | - * |
|
129 | - * @param string $varName |
|
130 | - * @param mixed $varValue |
|
131 | - * @return string |
|
132 | - */ |
|
114 | + /** |
|
115 | + * Builds a set variable statement. The variable value is |
|
116 | + * automatically converted to the javascript equivalent. |
|
117 | + * |
|
118 | + * Examples: |
|
119 | + * |
|
120 | + * // foo = 'bar'; |
|
121 | + * JSHelper::buildVariable('foo', 'bar'); |
|
122 | + * |
|
123 | + * // foo = 42; |
|
124 | + * JSHelper::buildVariable('foo', 42); |
|
125 | + * |
|
126 | + * // foo = true; |
|
127 | + * JSHelper::buildVariable('foo', true); |
|
128 | + * |
|
129 | + * @param string $varName |
|
130 | + * @param mixed $varValue |
|
131 | + * @return string |
|
132 | + */ |
|
133 | 133 | public static function buildVariable(string $varName, $varValue) : string |
134 | 134 | { |
135 | 135 | return $varName . "=" . self::phpVariable2JS($varValue) . ';'; |
136 | 136 | } |
137 | 137 | |
138 | - /** |
|
139 | - * Converts a PHP variable to its javascript equivalent. Note that |
|
140 | - * if a variable cannot be converted (like a PHP resource), this will |
|
141 | - * return a javascript "null". |
|
142 | - * |
|
143 | - * @param mixed $variable |
|
144 | - * @param int $quoteStyle The quote style to use for strings |
|
145 | - * @return string |
|
146 | - */ |
|
138 | + /** |
|
139 | + * Converts a PHP variable to its javascript equivalent. Note that |
|
140 | + * if a variable cannot be converted (like a PHP resource), this will |
|
141 | + * return a javascript "null". |
|
142 | + * |
|
143 | + * @param mixed $variable |
|
144 | + * @param int $quoteStyle The quote style to use for strings |
|
145 | + * @return string |
|
146 | + */ |
|
147 | 147 | public static function phpVariable2JS($variable, int $quoteStyle=self::QUOTE_STYLE_DOUBLE) : string |
148 | 148 | { |
149 | 149 | // after much profiling, this variant of the method offers |
@@ -221,26 +221,26 @@ discard block |
||
221 | 221 | return $result; |
222 | 222 | } |
223 | 223 | |
224 | - /** |
|
225 | - * Converts a variable to a JS string that can be |
|
226 | - * used in an HTML attribute: it uses single quotes |
|
227 | - * instead of the default double quotes. |
|
228 | - * |
|
229 | - * @param mixed $variable |
|
230 | - * @return string |
|
231 | - */ |
|
224 | + /** |
|
225 | + * Converts a variable to a JS string that can be |
|
226 | + * used in an HTML attribute: it uses single quotes |
|
227 | + * instead of the default double quotes. |
|
228 | + * |
|
229 | + * @param mixed $variable |
|
230 | + * @return string |
|
231 | + */ |
|
232 | 232 | public static function phpVariable2AttributeJS($variable) : string |
233 | 233 | { |
234 | 234 | return self::phpVariable2JS($variable, self::QUOTE_STYLE_SINGLE); |
235 | 235 | } |
236 | 236 | |
237 | - /** |
|
238 | - * Generates a dynamic element ID to be used with dynamically generated |
|
239 | - * HTML code to tie in with clientside javascript when compact but unique |
|
240 | - * IDs are needed in a request. |
|
241 | - * |
|
242 | - * @return string |
|
243 | - */ |
|
237 | + /** |
|
238 | + * Generates a dynamic element ID to be used with dynamically generated |
|
239 | + * HTML code to tie in with clientside javascript when compact but unique |
|
240 | + * IDs are needed in a request. |
|
241 | + * |
|
242 | + * @return string |
|
243 | + */ |
|
244 | 244 | public static function nextElementID() : string |
245 | 245 | { |
246 | 246 | self::$elementCounter++; |
@@ -248,33 +248,33 @@ discard block |
||
248 | 248 | return self::$idPrefix . self::$elementCounter; |
249 | 249 | } |
250 | 250 | |
251 | - /** |
|
252 | - * Retrieves the ID prefix currently used. |
|
253 | - * |
|
254 | - * @return string |
|
255 | - */ |
|
251 | + /** |
|
252 | + * Retrieves the ID prefix currently used. |
|
253 | + * |
|
254 | + * @return string |
|
255 | + */ |
|
256 | 256 | public static function getIDPrefix() : string |
257 | 257 | { |
258 | 258 | return self::$idPrefix; |
259 | 259 | } |
260 | 260 | |
261 | - /** |
|
262 | - * Retrieves the value of the internal elements counter. |
|
263 | - * |
|
264 | - * @return integer |
|
265 | - */ |
|
261 | + /** |
|
262 | + * Retrieves the value of the internal elements counter. |
|
263 | + * |
|
264 | + * @return integer |
|
265 | + */ |
|
266 | 266 | public static function getElementCounter() : int |
267 | 267 | { |
268 | 268 | return self::$elementCounter; |
269 | 269 | } |
270 | 270 | |
271 | - /** |
|
272 | - * Sets the prefix that is added in front of all IDs |
|
273 | - * retrieved using the {@link nextElementID()} method. |
|
274 | - * |
|
275 | - * @param string $prefix |
|
276 | - * @see JSHelper::nextElementID() |
|
277 | - */ |
|
271 | + /** |
|
272 | + * Sets the prefix that is added in front of all IDs |
|
273 | + * retrieved using the {@link nextElementID()} method. |
|
274 | + * |
|
275 | + * @param string $prefix |
|
276 | + * @see JSHelper::nextElementID() |
|
277 | + */ |
|
278 | 278 | public static function setIDPrefix(string $prefix) |
279 | 279 | { |
280 | 280 | self::$idPrefix = $prefix; |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | { |
47 | 47 | public const ERROR_FAILED_CONVERTING_TO_JSON = 37901; |
48 | 48 | |
49 | - /** |
|
50 | - * @var SimpleXMLElement |
|
51 | - */ |
|
49 | + /** |
|
50 | + * @var SimpleXMLElement |
|
51 | + */ |
|
52 | 52 | protected $xml; |
53 | 53 | |
54 | - /** |
|
55 | - * @var string|NULL |
|
56 | - */ |
|
54 | + /** |
|
55 | + * @var string|NULL |
|
56 | + */ |
|
57 | 57 | protected $json; |
58 | 58 | |
59 | 59 | protected function __construct(SimpleXMLElement $element) |
@@ -86,34 +86,34 @@ discard block |
||
86 | 86 | return self::fromElement(new SimpleXMLElement($xmlString)); |
87 | 87 | } |
88 | 88 | |
89 | - /** |
|
90 | - * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
91 | - * |
|
92 | - * @param SimpleXMLElement $element |
|
93 | - * @return XMLHelper_Converter |
|
94 | - */ |
|
89 | + /** |
|
90 | + * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
91 | + * |
|
92 | + * @param SimpleXMLElement $element |
|
93 | + * @return XMLHelper_Converter |
|
94 | + */ |
|
95 | 95 | public static function fromElement(SimpleXMLElement $element) : XMLHelper_Converter |
96 | 96 | { |
97 | 97 | return new XMLHelper_Converter($element); |
98 | 98 | } |
99 | 99 | |
100 | - /** |
|
101 | - * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
102 | - * |
|
103 | - * @param DOMElement $element |
|
104 | - * @return XMLHelper_Converter |
|
105 | - */ |
|
100 | + /** |
|
101 | + * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
102 | + * |
|
103 | + * @param DOMElement $element |
|
104 | + * @return XMLHelper_Converter |
|
105 | + */ |
|
106 | 106 | public static function fromDOMElement(DOMElement $element) : XMLHelper_Converter |
107 | 107 | { |
108 | 108 | return new XMLHelper_Converter(simplexml_import_dom($element)); |
109 | 109 | } |
110 | 110 | |
111 | - /** |
|
112 | - * Converts the XML to JSON. |
|
113 | - * |
|
114 | - * @return string |
|
115 | - * @throws XMLHelper_Exception|JsonException |
|
116 | - */ |
|
111 | + /** |
|
112 | + * Converts the XML to JSON. |
|
113 | + * |
|
114 | + * @return string |
|
115 | + * @throws XMLHelper_Exception|JsonException |
|
116 | + */ |
|
117 | 117 | public function toJSON() : string |
118 | 118 | { |
119 | 119 | if (isset($this->json)) |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - /** |
|
150 | - * Converts the XML to an associative array. |
|
151 | - * @return array |
|
152 | - * @throws XMLHelper_Exception|JsonException |
|
153 | - */ |
|
149 | + /** |
|
150 | + * Converts the XML to an associative array. |
|
151 | + * @return array |
|
152 | + * @throws XMLHelper_Exception|JsonException |
|
153 | + */ |
|
154 | 154 | public function toArray() : array |
155 | 155 | { |
156 | 156 | $json = $this->toJSON(); |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | { |
24 | 24 | public 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); |
@@ -24,9 +24,9 @@ |
||
24 | 24 | public const ERROR_CANNOT_UNSERIALIZE_ERROR_DATA = 57201; |
25 | 25 | public 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 | public 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(); |