@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | { |
24 | 24 | use Traits_Optionable; |
25 | 25 | |
26 | - /** |
|
27 | - * @var array<string,mixed> |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var array<string,mixed> |
|
28 | + */ |
|
29 | 29 | private array $overrides = array(); |
30 | 30 | |
31 | - /** |
|
32 | - * @var Request_RefreshParams_Exclude[] |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var Request_RefreshParams_Exclude[] |
|
33 | + */ |
|
34 | 34 | private array $excludes = array(); |
35 | 35 | |
36 | 36 | public function getDefaultOptions() : array |
@@ -41,27 +41,27 @@ discard block |
||
41 | 41 | ); |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * Whether to automatically exclude the session variable |
|
46 | - * from the parameters. |
|
47 | - * |
|
48 | - * @param bool $exclude |
|
49 | - * @return Request_RefreshParams |
|
50 | - */ |
|
44 | + /** |
|
45 | + * Whether to automatically exclude the session variable |
|
46 | + * from the parameters. |
|
47 | + * |
|
48 | + * @param bool $exclude |
|
49 | + * @return Request_RefreshParams |
|
50 | + */ |
|
51 | 51 | public function setExcludeSessionName(bool $exclude=true) : Request_RefreshParams |
52 | 52 | { |
53 | 53 | $this->setOption('exclude-session-name', $exclude); |
54 | 54 | return $this; |
55 | 55 | } |
56 | 56 | |
57 | - /** |
|
58 | - * Whether to automatically exclude the HTML_QuickForm2 |
|
59 | - * request variable used to track whether a form has been |
|
60 | - * submitted. |
|
61 | - * |
|
62 | - * @param bool $exclude |
|
63 | - * @return Request_RefreshParams |
|
64 | - */ |
|
57 | + /** |
|
58 | + * Whether to automatically exclude the HTML_QuickForm2 |
|
59 | + * request variable used to track whether a form has been |
|
60 | + * submitted. |
|
61 | + * |
|
62 | + * @param bool $exclude |
|
63 | + * @return Request_RefreshParams |
|
64 | + */ |
|
65 | 65 | public function setExcludeQuickform(bool $exclude) : Request_RefreshParams |
66 | 66 | { |
67 | 67 | $this->setOption('exclude-quickform-submitter', $exclude); |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
102 | - /** |
|
103 | - * Excludes a request parameter by name. |
|
104 | - * |
|
105 | - * @param array<int,string|number> $paramNames |
|
106 | - * @return Request_RefreshParams |
|
107 | - */ |
|
102 | + /** |
|
103 | + * Excludes a request parameter by name. |
|
104 | + * |
|
105 | + * @param array<int,string|number> $paramNames |
|
106 | + * @return Request_RefreshParams |
|
107 | + */ |
|
108 | 108 | public function excludeParamsByName(array $paramNames) : Request_RefreshParams |
109 | 109 | { |
110 | 110 | foreach($paramNames as $name) |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | return $this; |
116 | 116 | } |
117 | 117 | |
118 | - /** |
|
119 | - * Overrides a parameter: even if it exists, this |
|
120 | - * value will be used instead - even if it is on |
|
121 | - * the list of excluded parameters. |
|
122 | - * |
|
123 | - * @param string $paramName |
|
124 | - * @param mixed $paramValue |
|
125 | - * @return Request_RefreshParams |
|
126 | - */ |
|
118 | + /** |
|
119 | + * Overrides a parameter: even if it exists, this |
|
120 | + * value will be used instead - even if it is on |
|
121 | + * the list of excluded parameters. |
|
122 | + * |
|
123 | + * @param string $paramName |
|
124 | + * @param mixed $paramValue |
|
125 | + * @return Request_RefreshParams |
|
126 | + */ |
|
127 | 127 | public function overrideParam(string $paramName, $paramValue) : Request_RefreshParams |
128 | 128 | { |
129 | 129 | $this->overrides[$paramName] = $paramValue; |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | return $this; |
132 | 132 | } |
133 | 133 | |
134 | - /** |
|
135 | - * Overrides an array of parameters. |
|
136 | - * |
|
137 | - * @param array<string|number,mixed> $params |
|
138 | - * @return Request_RefreshParams |
|
139 | - */ |
|
134 | + /** |
|
135 | + * Overrides an array of parameters. |
|
136 | + * |
|
137 | + * @param array<string|number,mixed> $params |
|
138 | + * @return Request_RefreshParams |
|
139 | + */ |
|
140 | 140 | public function overrideParams(array $params) : Request_RefreshParams |
141 | 141 | { |
142 | 142 | foreach($params as $name => $value) |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | return $this; |
148 | 148 | } |
149 | 149 | |
150 | - /** |
|
151 | - * Resolves all the parameter exclusions that should |
|
152 | - * be applied to the list of parameters. This includes |
|
153 | - * the manually added exclusions and the dynamic exclusions |
|
154 | - * like the session name. |
|
155 | - * |
|
156 | - * @return Request_RefreshParams_Exclude[] |
|
157 | - */ |
|
150 | + /** |
|
151 | + * Resolves all the parameter exclusions that should |
|
152 | + * be applied to the list of parameters. This includes |
|
153 | + * the manually added exclusions and the dynamic exclusions |
|
154 | + * like the session name. |
|
155 | + * |
|
156 | + * @return Request_RefreshParams_Exclude[] |
|
157 | + */ |
|
158 | 158 | private function resolveExcludes() : array |
159 | 159 | { |
160 | 160 | $excludes = $this->excludes; |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | return $excludes; |
166 | 166 | } |
167 | 167 | |
168 | - /** |
|
169 | - * Automatically excludes the session name from the |
|
170 | - * parameters, if present. |
|
171 | - * |
|
172 | - * @param Request_RefreshParams_Exclude[] $excludes |
|
173 | - */ |
|
168 | + /** |
|
169 | + * Automatically excludes the session name from the |
|
170 | + * parameters, if present. |
|
171 | + * |
|
172 | + * @param Request_RefreshParams_Exclude[] $excludes |
|
173 | + */ |
|
174 | 174 | private function autoExcludeSessionName(array &$excludes) : void |
175 | 175 | { |
176 | 176 | if($this->getBoolOption('exclude-session-name')) |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Automatically excludes the HTML_QuickForm2 submit |
|
184 | - * tracking variable, when enabled. |
|
185 | - * |
|
186 | - * @param Request_RefreshParams_Exclude[] $excludes |
|
187 | - */ |
|
182 | + /** |
|
183 | + * Automatically excludes the HTML_QuickForm2 submit |
|
184 | + * tracking variable, when enabled. |
|
185 | + * |
|
186 | + * @param Request_RefreshParams_Exclude[] $excludes |
|
187 | + */ |
|
188 | 188 | private function autoExcludeQuickform(array &$excludes) : void |
189 | 189 | { |
190 | 190 | if($this->getBoolOption('exclude-quickform-submitter')) |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - /** |
|
200 | - * Retrieves the list of parameters matching the |
|
201 | - * current settings. |
|
202 | - * |
|
203 | - * @return array<string,mixed> |
|
204 | - */ |
|
199 | + /** |
|
200 | + * Retrieves the list of parameters matching the |
|
201 | + * current settings. |
|
202 | + * |
|
203 | + * @return array<string,mixed> |
|
204 | + */ |
|
205 | 205 | public function getParams() : array |
206 | 206 | { |
207 | 207 | $params = $this->removeExcluded($_REQUEST); |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | return $params; |
218 | 218 | } |
219 | 219 | |
220 | - /** |
|
221 | - * Removes all excluded parameters from the array. |
|
222 | - * |
|
223 | - * @param array<string,mixed> $params |
|
224 | - * @return array<string,mixed> |
|
225 | - */ |
|
220 | + /** |
|
221 | + * Removes all excluded parameters from the array. |
|
222 | + * |
|
223 | + * @param array<string,mixed> $params |
|
224 | + * @return array<string,mixed> |
|
225 | + */ |
|
226 | 226 | private function removeExcluded(array $params) : array |
227 | 227 | { |
228 | 228 | $result = array(); |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | return $result; |
241 | 241 | } |
242 | 242 | |
243 | - /** |
|
244 | - * Checks all configured exclusions to see if the |
|
245 | - * parameter should be excluded or not. |
|
246 | - * |
|
247 | - * @param string $paramName |
|
248 | - * @param mixed $paramValue |
|
249 | - * @return bool |
|
250 | - */ |
|
243 | + /** |
|
244 | + * Checks all configured exclusions to see if the |
|
245 | + * parameter should be excluded or not. |
|
246 | + * |
|
247 | + * @param string $paramName |
|
248 | + * @param mixed $paramValue |
|
249 | + * @return bool |
|
250 | + */ |
|
251 | 251 | public function isExcluded(string $paramName, $paramValue) : bool |
252 | 252 | { |
253 | 253 | $excludes = $this->resolveExcludes(); |
@@ -20,9 +20,9 @@ |
||
20 | 20 | */ |
21 | 21 | class Request_RefreshParams_Exclude_Callback extends Request_RefreshParams_Exclude |
22 | 22 | { |
23 | - /** |
|
24 | - * @var callable |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var callable |
|
25 | + */ |
|
26 | 26 | private $callback; |
27 | 27 | |
28 | 28 | public function __construct(callable $callback) |
@@ -6,9 +6,9 @@ discard block |
||
6 | 6 | |
7 | 7 | abstract class VariableInfo_Renderer |
8 | 8 | { |
9 | - /** |
|
10 | - * @var mixed|NULL |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var mixed|NULL |
|
11 | + */ |
|
12 | 12 | protected $value; |
13 | 13 | |
14 | 14 | protected VariableInfo $info; |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | |
25 | 25 | abstract protected function init() : void; |
26 | 26 | |
27 | - /** |
|
28 | - * Renders the value to the target format. |
|
29 | - * |
|
30 | - * @return string |
|
31 | - */ |
|
27 | + /** |
|
28 | + * Renders the value to the target format. |
|
29 | + * |
|
30 | + * @return string |
|
31 | + */ |
|
32 | 32 | public function render() : string |
33 | 33 | { |
34 | 34 | return $this->_render(); |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | - /** |
|
82 | - * Creates and returns a new instance of the CSV builder which |
|
83 | - * can be used to build CSV from scratch. |
|
84 | - * |
|
85 | - * @return CSVHelper_Builder |
|
86 | - */ |
|
81 | + /** |
|
82 | + * Creates and returns a new instance of the CSV builder which |
|
83 | + * can be used to build CSV from scratch. |
|
84 | + * |
|
85 | + * @return CSVHelper_Builder |
|
86 | + */ |
|
87 | 87 | public static function createBuilder() : CSVHelper_Builder |
88 | 88 | { |
89 | 89 | return new CSVHelper_Builder(); |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | |
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * Loads CSV data from a string. |
|
96 | - * |
|
97 | - * Note: Use the {@link hasErrors()} method to |
|
98 | - * check if the string could be parsed correctly |
|
99 | - * afterwards. |
|
100 | - * |
|
101 | - * @param string $string |
|
102 | - * @return $this |
|
103 | - */ |
|
94 | + /** |
|
95 | + * Loads CSV data from a string. |
|
96 | + * |
|
97 | + * Note: Use the {@link hasErrors()} method to |
|
98 | + * check if the string could be parsed correctly |
|
99 | + * afterwards. |
|
100 | + * |
|
101 | + * @param string $string |
|
102 | + * @return $this |
|
103 | + */ |
|
104 | 104 | public function loadString(string $string) : self |
105 | 105 | { |
106 | 106 | // remove any UTF byte order marks that may still be present in the string |
@@ -114,20 +114,20 @@ discard block |
||
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | |
117 | - /** |
|
118 | - * Loads CSV data from a file. |
|
119 | - * |
|
120 | - * Note: Use the {@link hasErrors()} method to |
|
121 | - * check if the string could be parsed correctly |
|
122 | - * afterwards. |
|
123 | - * |
|
124 | - * @param string $file |
|
125 | - * @throws FileHelper_Exception |
|
126 | - * @return CSVHelper |
|
127 | - * |
|
128 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
129 | - * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
130 | - */ |
|
117 | + /** |
|
118 | + * Loads CSV data from a file. |
|
119 | + * |
|
120 | + * Note: Use the {@link hasErrors()} method to |
|
121 | + * check if the string could be parsed correctly |
|
122 | + * afterwards. |
|
123 | + * |
|
124 | + * @param string $file |
|
125 | + * @throws FileHelper_Exception |
|
126 | + * @return CSVHelper |
|
127 | + * |
|
128 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
129 | + * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
130 | + */ |
|
131 | 131 | public function loadFile(string $file) : self |
132 | 132 | { |
133 | 133 | $csv = FileHelper::readContents($file); |
@@ -188,19 +188,19 @@ discard block |
||
188 | 188 | return $this->headersPosition === $position; |
189 | 189 | } |
190 | 190 | |
191 | - /** |
|
192 | - * Specifies where the headers are positioned in the |
|
193 | - * CSV, or turns them off entirely. Use the class constants |
|
194 | - * to ensure the value is correct. |
|
195 | - * |
|
196 | - * @param string $position |
|
197 | - * @throws CSVHelper_Exception |
|
198 | - * @return $this |
|
199 | - * |
|
200 | - * @see CSVHelper::HEADERS_LEFT |
|
201 | - * @see CSVHelper::HEADERS_TOP |
|
202 | - * @see CSVHelper::HEADERS_NONE |
|
203 | - */ |
|
191 | + /** |
|
192 | + * Specifies where the headers are positioned in the |
|
193 | + * CSV, or turns them off entirely. Use the class constants |
|
194 | + * to ensure the value is correct. |
|
195 | + * |
|
196 | + * @param string $position |
|
197 | + * @throws CSVHelper_Exception |
|
198 | + * @return $this |
|
199 | + * |
|
200 | + * @see CSVHelper::HEADERS_LEFT |
|
201 | + * @see CSVHelper::HEADERS_TOP |
|
202 | + * @see CSVHelper::HEADERS_NONE |
|
203 | + */ |
|
204 | 204 | public function setHeadersPosition(string $position) : self |
205 | 205 | { |
206 | 206 | $validPositions = array( |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | return $this; |
228 | 228 | } |
229 | 229 | |
230 | - /** |
|
231 | - * Resets all internal data, allowing to start entirely anew |
|
232 | - * with a new file, or to start building a new CSV file from |
|
233 | - * scratch. |
|
234 | - * |
|
235 | - * @return $this |
|
236 | - */ |
|
230 | + /** |
|
231 | + * Resets all internal data, allowing to start entirely anew |
|
232 | + * with a new file, or to start building a new CSV file from |
|
233 | + * scratch. |
|
234 | + * |
|
235 | + * @return $this |
|
236 | + */ |
|
237 | 237 | public function reset() : self |
238 | 238 | { |
239 | 239 | $this->data = array(); |
@@ -253,81 +253,81 @@ discard block |
||
253 | 253 | return $this->data; |
254 | 254 | } |
255 | 255 | |
256 | - /** |
|
257 | - * Retrieves the row at the specified index. |
|
258 | - * If there is no data at the index, this will |
|
259 | - * return an array populated with empty strings |
|
260 | - * for all available columns. |
|
261 | - * |
|
262 | - * Tip: Use the {@link rowExists()} method to check |
|
263 | - * whether the specified row exists. |
|
264 | - * |
|
265 | - * @param integer $index |
|
266 | - * @return array<int,mixed> |
|
267 | - * @see rowExists() |
|
268 | - */ |
|
256 | + /** |
|
257 | + * Retrieves the row at the specified index. |
|
258 | + * If there is no data at the index, this will |
|
259 | + * return an array populated with empty strings |
|
260 | + * for all available columns. |
|
261 | + * |
|
262 | + * Tip: Use the {@link rowExists()} method to check |
|
263 | + * whether the specified row exists. |
|
264 | + * |
|
265 | + * @param integer $index |
|
266 | + * @return array<int,mixed> |
|
267 | + * @see rowExists() |
|
268 | + */ |
|
269 | 269 | public function getRow(int $index) : array |
270 | 270 | { |
271 | 271 | return $this->data[$index] ?? array_fill(0, $this->rowCount, ''); |
272 | 272 | } |
273 | 273 | |
274 | - /** |
|
275 | - * Checks whether the specified row exists in the data set. |
|
276 | - * @param integer $index |
|
277 | - * @return boolean |
|
278 | - */ |
|
274 | + /** |
|
275 | + * Checks whether the specified row exists in the data set. |
|
276 | + * @param integer $index |
|
277 | + * @return boolean |
|
278 | + */ |
|
279 | 279 | public function rowExists(int $index) : bool |
280 | 280 | { |
281 | 281 | return isset($this->data[$index]); |
282 | 282 | } |
283 | 283 | |
284 | - /** |
|
285 | - * Counts the amount of rows in the parsed CSV, |
|
286 | - * excluding the headers if any, depending on |
|
287 | - * their position. |
|
288 | - * |
|
289 | - * @return integer |
|
290 | - */ |
|
284 | + /** |
|
285 | + * Counts the amount of rows in the parsed CSV, |
|
286 | + * excluding the headers if any, depending on |
|
287 | + * their position. |
|
288 | + * |
|
289 | + * @return integer |
|
290 | + */ |
|
291 | 291 | public function countRows() : int |
292 | 292 | { |
293 | 293 | return $this->rowCount; |
294 | 294 | } |
295 | 295 | |
296 | - /** |
|
297 | - * Counts the amount of rows in the parsed CSV, |
|
298 | - * excluding the headers if any, depending on |
|
299 | - * their position. |
|
300 | - * |
|
301 | - * @return integer |
|
302 | - */ |
|
296 | + /** |
|
297 | + * Counts the amount of rows in the parsed CSV, |
|
298 | + * excluding the headers if any, depending on |
|
299 | + * their position. |
|
300 | + * |
|
301 | + * @return integer |
|
302 | + */ |
|
303 | 303 | public function countColumns() : int |
304 | 304 | { |
305 | 305 | return $this->columnCount; |
306 | 306 | } |
307 | 307 | |
308 | - /** |
|
309 | - * Retrieves the headers, if any. Specify the position of the |
|
310 | - * headers first to ensure this works correctly. |
|
311 | - * |
|
312 | - * @return string[] Indexed array with header names. |
|
313 | - */ |
|
308 | + /** |
|
309 | + * Retrieves the headers, if any. Specify the position of the |
|
310 | + * headers first to ensure this works correctly. |
|
311 | + * |
|
312 | + * @return string[] Indexed array with header names. |
|
313 | + */ |
|
314 | 314 | public function getHeaders() : array |
315 | 315 | { |
316 | 316 | return $this->headers; |
317 | 317 | } |
318 | 318 | |
319 | - /** |
|
320 | - * Retrieves the column at the specified index. If there |
|
321 | - * is no column at the index, this returns an array |
|
322 | - * populated with empty strings. |
|
323 | - * |
|
324 | - * Tip: Use the {@link columnExists()} method to check |
|
325 | - * whether a column exists. |
|
326 | - * |
|
327 | - * @param integer $index |
|
328 | - * @return string[] |
|
329 | - * @see columnExists() |
|
330 | - */ |
|
319 | + /** |
|
320 | + * Retrieves the column at the specified index. If there |
|
321 | + * is no column at the index, this returns an array |
|
322 | + * populated with empty strings. |
|
323 | + * |
|
324 | + * Tip: Use the {@link columnExists()} method to check |
|
325 | + * whether a column exists. |
|
326 | + * |
|
327 | + * @param integer $index |
|
328 | + * @return string[] |
|
329 | + * @see columnExists() |
|
330 | + */ |
|
331 | 331 | public function getColumn(int $index) : array |
332 | 332 | { |
333 | 333 | $data = array(); |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | return $data; |
343 | 343 | } |
344 | 344 | |
345 | - /** |
|
346 | - * Checks whether the specified column exists in the data set. |
|
347 | - * @param integer $index |
|
348 | - * @return boolean |
|
349 | - */ |
|
345 | + /** |
|
346 | + * Checks whether the specified column exists in the data set. |
|
347 | + * @param integer $index |
|
348 | + * @return boolean |
|
349 | + */ |
|
350 | 350 | public function columnExists(int $index) : bool |
351 | 351 | { |
352 | 352 | return $index < $this->columnCount; |
@@ -406,22 +406,22 @@ discard block |
||
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
409 | - /** |
|
410 | - * Checks whether any errors have been encountered |
|
411 | - * while parsing the CSV. |
|
412 | - * |
|
413 | - * @return boolean |
|
414 | - * @see getErrorMessages() |
|
415 | - */ |
|
409 | + /** |
|
410 | + * Checks whether any errors have been encountered |
|
411 | + * while parsing the CSV. |
|
412 | + * |
|
413 | + * @return boolean |
|
414 | + * @see getErrorMessages() |
|
415 | + */ |
|
416 | 416 | public function hasErrors() : bool |
417 | 417 | { |
418 | 418 | return !empty($this->errors); |
419 | 419 | } |
420 | 420 | |
421 | - /** |
|
422 | - * Retrieves all error messages. |
|
423 | - * @return string[] |
|
424 | - */ |
|
421 | + /** |
|
422 | + * Retrieves all error messages. |
|
423 | + * @return string[] |
|
424 | + */ |
|
425 | 425 | public function getErrorMessages() : array |
426 | 426 | { |
427 | 427 | return $this->errors; |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | ); |
44 | 44 | } |
45 | 45 | |
46 | - /** |
|
47 | - * Whether to verify the host's SSL certificate, in |
|
48 | - * case of a https connection. |
|
49 | - * |
|
50 | - * @param bool $verifySSL |
|
51 | - * @return URIConnectionTester |
|
52 | - */ |
|
46 | + /** |
|
47 | + * Whether to verify the host's SSL certificate, in |
|
48 | + * case of a https connection. |
|
49 | + * |
|
50 | + * @param bool $verifySSL |
|
51 | + * @return URIConnectionTester |
|
52 | + */ |
|
53 | 53 | public function setVerifySSL(bool $verifySSL=true) : URIConnectionTester |
54 | 54 | { |
55 | 55 | $this->setOption('verify-ssl', $verifySSL); |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | return $this->getIntOption('timeout'); |
84 | 84 | } |
85 | 85 | |
86 | - /** |
|
87 | - * @param resource|CurlHandle $ch |
|
88 | - */ |
|
86 | + /** |
|
87 | + * @param resource|CurlHandle $ch |
|
88 | + */ |
|
89 | 89 | private function configureOptions($ch) : void |
90 | 90 | { |
91 | 91 | if($this->isVerboseModeEnabled()) |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | protected int $contentLength = 0; |
47 | 47 | |
48 | 48 | /** |
49 | - * @var array<string,string> |
|
50 | - */ |
|
49 | + * @var array<string,string> |
|
50 | + */ |
|
51 | 51 | protected $headers = array(); |
52 | 52 | |
53 | - /** |
|
54 | - * @var resource|NULL |
|
55 | - */ |
|
53 | + /** |
|
54 | + * @var resource|NULL |
|
55 | + */ |
|
56 | 56 | protected $logfilePointer; |
57 | 57 | |
58 | - /** |
|
59 | - * Creates a new request helper to send POST data to the specified destination URL. |
|
60 | - * @param string $destinationURL |
|
61 | - */ |
|
58 | + /** |
|
59 | + * Creates a new request helper to send POST data to the specified destination URL. |
|
60 | + * @param string $destinationURL |
|
61 | + */ |
|
62 | 62 | public function __construct(string $destinationURL) |
63 | 63 | { |
64 | 64 | $this->destination = $destinationURL; |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | return $this->eol; |
82 | 82 | } |
83 | 83 | |
84 | - /** |
|
85 | - * Sets the timeout for the request, in seconds. If the request |
|
86 | - * takes longer, it will be cancelled and an exception triggered. |
|
87 | - * |
|
88 | - * @param int $seconds |
|
89 | - * @return RequestHelper |
|
90 | - */ |
|
84 | + /** |
|
85 | + * Sets the timeout for the request, in seconds. If the request |
|
86 | + * takes longer, it will be cancelled and an exception triggered. |
|
87 | + * |
|
88 | + * @param int $seconds |
|
89 | + * @return RequestHelper |
|
90 | + */ |
|
91 | 91 | public function setTimeout(int $seconds) : RequestHelper |
92 | 92 | { |
93 | 93 | $this->timeout = $seconds; |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | return $this->timeout; |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
104 | - * Enables verbose logging of the CURL request, which |
|
105 | - * is then redirected to the target file. |
|
106 | - * |
|
107 | - * @param string $targetFile |
|
108 | - * @return RequestHelper |
|
109 | - */ |
|
103 | + /** |
|
104 | + * Enables verbose logging of the CURL request, which |
|
105 | + * is then redirected to the target file. |
|
106 | + * |
|
107 | + * @param string $targetFile |
|
108 | + * @return RequestHelper |
|
109 | + */ |
|
110 | 110 | public function enableLogging(string $targetFile) : RequestHelper |
111 | 111 | { |
112 | 112 | $this->logfile = $targetFile; |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | |
117 | - /** |
|
118 | - * Adds a file to be sent with the request. |
|
119 | - * |
|
120 | - * @param string $varName The variable name to send the file in |
|
121 | - * @param string $fileName The name of the file as it should be received at the destination |
|
122 | - * @param string $content The raw content of the file |
|
123 | - * @param string $contentType The content type, use the constants to specify this |
|
124 | - * @param string $encoding The encoding of the file, use the constants to specify this |
|
125 | - */ |
|
117 | + /** |
|
118 | + * Adds a file to be sent with the request. |
|
119 | + * |
|
120 | + * @param string $varName The variable name to send the file in |
|
121 | + * @param string $fileName The name of the file as it should be received at the destination |
|
122 | + * @param string $content The raw content of the file |
|
123 | + * @param string $contentType The content type, use the constants to specify this |
|
124 | + * @param string $encoding The encoding of the file, use the constants to specify this |
|
125 | + */ |
|
126 | 126 | public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper |
127 | 127 | { |
128 | 128 | $this->boundaries->addFile($varName, $fileName, $content, $contentType, $encoding); |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | return $this; |
161 | 161 | } |
162 | 162 | |
163 | - /** |
|
164 | - * Sets an HTTP header to include in the request. |
|
165 | - * |
|
166 | - * @param string $name |
|
167 | - * @param string $value |
|
168 | - * @return RequestHelper |
|
169 | - */ |
|
163 | + /** |
|
164 | + * Sets an HTTP header to include in the request. |
|
165 | + * |
|
166 | + * @param string $name |
|
167 | + * @param string $value |
|
168 | + * @return RequestHelper |
|
169 | + */ |
|
170 | 170 | public function setHeader(string $name, string $value) : RequestHelper |
171 | 171 | { |
172 | 172 | $this->headers[$name] = $value; |
@@ -174,31 +174,31 @@ discard block |
||
174 | 174 | return $this; |
175 | 175 | } |
176 | 176 | |
177 | - /** |
|
178 | - * Disables SSL certificate checking. |
|
179 | - * |
|
180 | - * @return RequestHelper |
|
181 | - */ |
|
177 | + /** |
|
178 | + * Disables SSL certificate checking. |
|
179 | + * |
|
180 | + * @return RequestHelper |
|
181 | + */ |
|
182 | 182 | public function disableSSLChecks() : RequestHelper |
183 | 183 | { |
184 | 184 | $this->verifySSL = false; |
185 | 185 | return $this; |
186 | 186 | } |
187 | 187 | |
188 | - /** |
|
189 | - * Sends the POST request to the destination, and returns |
|
190 | - * the response text. |
|
191 | - * |
|
192 | - * The response object is stored internally, so after calling |
|
193 | - * this method it may be retrieved at any moment using the |
|
194 | - * {@link getResponse()} method. |
|
195 | - * |
|
196 | - * @return string |
|
197 | - * @see RequestHelper::getResponse() |
|
198 | - * @throws RequestHelper_Exception |
|
199 | - * |
|
200 | - * @see RequestHelper::ERROR_REQUEST_FAILED |
|
201 | - */ |
|
188 | + /** |
|
189 | + * Sends the POST request to the destination, and returns |
|
190 | + * the response text. |
|
191 | + * |
|
192 | + * The response object is stored internally, so after calling |
|
193 | + * this method it may be retrieved at any moment using the |
|
194 | + * {@link getResponse()} method. |
|
195 | + * |
|
196 | + * @return string |
|
197 | + * @see RequestHelper::getResponse() |
|
198 | + * @throws RequestHelper_Exception |
|
199 | + * |
|
200 | + * @see RequestHelper::ERROR_REQUEST_FAILED |
|
201 | + */ |
|
202 | 202 | public function send() : string |
203 | 203 | { |
204 | 204 | $info = parseURL($this->destination); |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | return $this->response->getResponseBody(); |
239 | 239 | } |
240 | 240 | |
241 | - /** |
|
242 | - * Retrieves the request's body content. This is an alias |
|
243 | - * for {@see RequestHelper::getMimeBody()}. |
|
244 | - * |
|
245 | - * @return string |
|
246 | - * @see RequestHelper::getMimeBody() |
|
247 | - */ |
|
241 | + /** |
|
242 | + * Retrieves the request's body content. This is an alias |
|
243 | + * for {@see RequestHelper::getMimeBody()}. |
|
244 | + * |
|
245 | + * @return string |
|
246 | + * @see RequestHelper::getMimeBody() |
|
247 | + */ |
|
248 | 248 | public function getBody() : string |
249 | 249 | { |
250 | 250 | return $this->getMimeBody(); |
@@ -276,14 +276,14 @@ discard block |
||
276 | 276 | ); |
277 | 277 | } |
278 | 278 | |
279 | - /** |
|
280 | - * Creates a new CURL resource configured according to the |
|
281 | - * request's settings. |
|
282 | - * |
|
283 | - * @param URLInfo $url |
|
284 | - * @throws RequestHelper_Exception |
|
285 | - * @return resource |
|
286 | - */ |
|
279 | + /** |
|
280 | + * Creates a new CURL resource configured according to the |
|
281 | + * request's settings. |
|
282 | + * |
|
283 | + * @param URLInfo $url |
|
284 | + * @throws RequestHelper_Exception |
|
285 | + * @return resource |
|
286 | + */ |
|
287 | 287 | protected function configureCURL(URLInfo $url) |
288 | 288 | { |
289 | 289 | $ch = self::createCURL(); |
@@ -353,13 +353,13 @@ discard block |
||
353 | 353 | return true; |
354 | 354 | } |
355 | 355 | |
356 | - /** |
|
357 | - * Compiles the associative headers array into |
|
358 | - * the format understood by CURL, namely an indexed |
|
359 | - * array with one header string per entry. |
|
360 | - * |
|
361 | - * @return string[] |
|
362 | - */ |
|
356 | + /** |
|
357 | + * Compiles the associative headers array into |
|
358 | + * the format understood by CURL, namely an indexed |
|
359 | + * array with one header string per entry. |
|
360 | + * |
|
361 | + * @return string[] |
|
362 | + */ |
|
363 | 363 | protected function renderHeaders() : array |
364 | 364 | { |
365 | 365 | $result = array(); |
@@ -373,12 +373,12 @@ discard block |
||
373 | 373 | return $result; |
374 | 374 | } |
375 | 375 | |
376 | - /** |
|
377 | - * Retrieves the raw response header, in the form of an indexed |
|
378 | - * array containing all response header lines. |
|
379 | - * |
|
380 | - * @return string[] |
|
381 | - */ |
|
376 | + /** |
|
377 | + * Retrieves the raw response header, in the form of an indexed |
|
378 | + * array containing all response header lines. |
|
379 | + * |
|
380 | + * @return string[] |
|
381 | + */ |
|
382 | 382 | public function getResponseHeader() : array |
383 | 383 | { |
384 | 384 | $response = $this->getResponse(); |
@@ -390,33 +390,33 @@ discard block |
||
390 | 390 | return array(); |
391 | 391 | } |
392 | 392 | |
393 | - /** |
|
394 | - * After calling the {@link send()} method, this may be used to |
|
395 | - * retrieve the response text from the POST request. |
|
396 | - * |
|
397 | - * @return RequestHelper_Response|NULL |
|
398 | - */ |
|
393 | + /** |
|
394 | + * After calling the {@link send()} method, this may be used to |
|
395 | + * retrieve the response text from the POST request. |
|
396 | + * |
|
397 | + * @return RequestHelper_Response|NULL |
|
398 | + */ |
|
399 | 399 | public function getResponse() : ?RequestHelper_Response |
400 | 400 | { |
401 | 401 | return $this->response; |
402 | 402 | } |
403 | 403 | |
404 | - /** |
|
405 | - * Retrieves all headers set until now. |
|
406 | - * |
|
407 | - * @return array<string,string> |
|
408 | - */ |
|
404 | + /** |
|
405 | + * Retrieves all headers set until now. |
|
406 | + * |
|
407 | + * @return array<string,string> |
|
408 | + */ |
|
409 | 409 | public function getHeaders() : array |
410 | 410 | { |
411 | 411 | return $this->headers; |
412 | 412 | } |
413 | 413 | |
414 | - /** |
|
415 | - * Retrieves the value of a header by its name. |
|
416 | - * |
|
417 | - * @param string $name |
|
418 | - * @return string The header value, or an empty string if not set. |
|
419 | - */ |
|
414 | + /** |
|
415 | + * Retrieves the value of a header by its name. |
|
416 | + * |
|
417 | + * @param string $name |
|
418 | + * @return string The header value, or an empty string if not set. |
|
419 | + */ |
|
420 | 420 | public function getHeader(string $name) : string |
421 | 421 | { |
422 | 422 | return $this->headers[$name] ?? ''; |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | protected array $colors = array(); |
74 | 74 | |
75 | 75 | /** |
76 | - * @var resource|NULL |
|
77 | - */ |
|
76 | + * @var resource|NULL |
|
77 | + */ |
|
78 | 78 | protected $newImage; |
79 | 79 | |
80 | - /** |
|
81 | - * @var resource |
|
82 | - */ |
|
80 | + /** |
|
81 | + * @var resource |
|
82 | + */ |
|
83 | 83 | protected $sourceImage; |
84 | 84 | |
85 | 85 | /** |
@@ -188,17 +188,17 @@ discard block |
||
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - /** |
|
192 | - * Factory method: creates a new helper with a blank image. |
|
193 | - * |
|
194 | - * @param integer $width |
|
195 | - * @param integer $height |
|
196 | - * @param string $type The target file type when saving |
|
197 | - * @return ImageHelper |
|
198 | - * @throws ImageHelper_Exception |
|
199 | - * |
|
200 | - * @see ImageHelper::ERROR_CANNOT_CREATE_IMAGE_OBJECT |
|
201 | - */ |
|
191 | + /** |
|
192 | + * Factory method: creates a new helper with a blank image. |
|
193 | + * |
|
194 | + * @param integer $width |
|
195 | + * @param integer $height |
|
196 | + * @param string $type The target file type when saving |
|
197 | + * @return ImageHelper |
|
198 | + * @throws ImageHelper_Exception |
|
199 | + * |
|
200 | + * @see ImageHelper::ERROR_CANNOT_CREATE_IMAGE_OBJECT |
|
201 | + */ |
|
202 | 202 | public static function createNew(int $width, int $height, string $type='png') : self |
203 | 203 | { |
204 | 204 | $img = imagecreatetruecolor($width, $height); |
@@ -249,17 +249,17 @@ discard block |
||
249 | 249 | return new ImageHelper($file, null, self::getFileImageType($file)); |
250 | 250 | } |
251 | 251 | |
252 | - /** |
|
253 | - * Sets a global image helper configuration value. Available |
|
254 | - * configuration settings are: |
|
255 | - * |
|
256 | - * <ul> |
|
257 | - * <li><code>auto-memory-adjustment</code> <i>boolean</i> Whether to try and adjust the memory limit automatically so there will be enough to load/process the target image.</li> |
|
258 | - * </ul> |
|
259 | - * |
|
260 | - * @param string $name |
|
261 | - * @param mixed|NULL $value |
|
262 | - */ |
|
252 | + /** |
|
253 | + * Sets a global image helper configuration value. Available |
|
254 | + * configuration settings are: |
|
255 | + * |
|
256 | + * <ul> |
|
257 | + * <li><code>auto-memory-adjustment</code> <i>boolean</i> Whether to try and adjust the memory limit automatically so there will be enough to load/process the target image.</li> |
|
258 | + * </ul> |
|
259 | + * |
|
260 | + * @param string $name |
|
261 | + * @param mixed|NULL $value |
|
262 | + */ |
|
263 | 263 | public static function setConfig(string $name, $value) : void |
264 | 264 | { |
265 | 265 | if(isset(self::$config[$name])) { |
@@ -267,13 +267,13 @@ discard block |
||
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
271 | - * Shorthand for setting the automatic memory adjustment |
|
272 | - * global configuration setting. |
|
273 | - * |
|
274 | - * @param bool $enabled |
|
275 | - * @return void |
|
276 | - */ |
|
270 | + /** |
|
271 | + * Shorthand for setting the automatic memory adjustment |
|
272 | + * global configuration setting. |
|
273 | + * |
|
274 | + * @param bool $enabled |
|
275 | + * @return void |
|
276 | + */ |
|
277 | 277 | public static function setAutoMemoryAdjustment(bool $enabled=true) : void |
278 | 278 | { |
279 | 279 | self::setConfig('auto-memory-adjustment', $enabled); |
@@ -747,12 +747,12 @@ discard block |
||
747 | 747 | return $this; |
748 | 748 | } |
749 | 749 | |
750 | - /** |
|
751 | - * Attempts to adjust the memory to the required size |
|
752 | - * to work with the current image. |
|
753 | - * |
|
754 | - * @return boolean |
|
755 | - */ |
|
750 | + /** |
|
751 | + * Attempts to adjust the memory to the required size |
|
752 | + * to work with the current image. |
|
753 | + * |
|
754 | + * @return boolean |
|
755 | + */ |
|
756 | 756 | protected function adjustMemory() : bool |
757 | 757 | { |
758 | 758 | if(!self::$config['auto-memory-adjustment']) { |
@@ -805,15 +805,15 @@ discard block |
||
805 | 805 | return $this->resampleImage($width, $height); |
806 | 806 | } |
807 | 807 | |
808 | - /** |
|
809 | - * Creates a new image from the current image, |
|
810 | - * resampling it to the new size. |
|
811 | - * |
|
812 | - * @param int $newWidth |
|
813 | - * @param int $newHeight |
|
814 | - * @throws ImageHelper_Exception |
|
815 | - * @return ImageHelper |
|
816 | - */ |
|
808 | + /** |
|
809 | + * Creates a new image from the current image, |
|
810 | + * resampling it to the new size. |
|
811 | + * |
|
812 | + * @param int $newWidth |
|
813 | + * @param int $newHeight |
|
814 | + * @throws ImageHelper_Exception |
|
815 | + * @return ImageHelper |
|
816 | + */ |
|
817 | 817 | protected function resampleImage(int $newWidth, int $newHeight) : ImageHelper |
818 | 818 | { |
819 | 819 | if($this->isVector()) { |
@@ -885,17 +885,17 @@ discard block |
||
885 | 885 | return array_unique($types); |
886 | 886 | } |
887 | 887 | |
888 | - /** |
|
889 | - * Displays an existing image resource. |
|
890 | - * |
|
891 | - * @param resource $resource |
|
892 | - * @param string $imageType The image format to send, i.e. "jpeg", "png" |
|
893 | - * @param int $quality The quality to use for the image. This is 0-9 (0=no compression, 9=max) for PNG, and 0-100 (0=lowest, 100=highest quality) for JPG |
|
894 | - * |
|
895 | - * @throws ImageHelper_Exception |
|
896 | - * @see ImageHelper::ERROR_NOT_A_RESOURCE |
|
897 | - * @see ImageHelper::ERROR_INVALID_STREAM_IMAGE_TYPE |
|
898 | - */ |
|
888 | + /** |
|
889 | + * Displays an existing image resource. |
|
890 | + * |
|
891 | + * @param resource $resource |
|
892 | + * @param string $imageType The image format to send, i.e. "jpeg", "png" |
|
893 | + * @param int $quality The quality to use for the image. This is 0-9 (0=no compression, 9=max) for PNG, and 0-100 (0=lowest, 100=highest quality) for JPG |
|
894 | + * |
|
895 | + * @throws ImageHelper_Exception |
|
896 | + * @see ImageHelper::ERROR_NOT_A_RESOURCE |
|
897 | + * @see ImageHelper::ERROR_INVALID_STREAM_IMAGE_TYPE |
|
898 | + */ |
|
899 | 899 | public static function displayImageStream($resource, string $imageType, int $quality=-1) : void |
900 | 900 | { |
901 | 901 | self::requireResource($resource); |
@@ -979,11 +979,11 @@ discard block |
||
979 | 979 | readfile($imageFile); |
980 | 980 | } |
981 | 981 | |
982 | - /** |
|
983 | - * Displays the current image. |
|
984 | - * |
|
985 | - * NOTE: You must call `exit()` manually after this. |
|
986 | - */ |
|
982 | + /** |
|
983 | + * Displays the current image. |
|
984 | + * |
|
985 | + * NOTE: You must call `exit()` manually after this. |
|
986 | + */ |
|
987 | 987 | public function display() : void |
988 | 988 | { |
989 | 989 | self::displayImageStream( |
@@ -1097,14 +1097,14 @@ discard block |
||
1097 | 1097 | return $this; |
1098 | 1098 | } |
1099 | 1099 | |
1100 | - /** |
|
1101 | - * Requires the subject to be a resource. |
|
1102 | - * |
|
1103 | - * @param resource|GdImage|mixed $subject |
|
1104 | - * |
|
1105 | - * @throws ImageHelper_Exception |
|
1106 | - * @see ImageHelper::ERROR_NOT_A_RESOURCE |
|
1107 | - */ |
|
1100 | + /** |
|
1101 | + * Requires the subject to be a resource. |
|
1102 | + * |
|
1103 | + * @param resource|GdImage|mixed $subject |
|
1104 | + * |
|
1105 | + * @throws ImageHelper_Exception |
|
1106 | + * @see ImageHelper::ERROR_NOT_A_RESOURCE |
|
1107 | + */ |
|
1108 | 1108 | public static function requireResource($subject) : void |
1109 | 1109 | { |
1110 | 1110 | if(is_resource($subject) && imagesx($subject)) { |
@@ -1125,14 +1125,14 @@ discard block |
||
1125 | 1125 | ); |
1126 | 1126 | } |
1127 | 1127 | |
1128 | - /** |
|
1129 | - * Creates a new image resource, with transparent background. |
|
1130 | - * |
|
1131 | - * @param int $width |
|
1132 | - * @param int $height |
|
1133 | - * @throws ImageHelper_Exception |
|
1134 | - * @return resource |
|
1135 | - */ |
|
1128 | + /** |
|
1129 | + * Creates a new image resource, with transparent background. |
|
1130 | + * |
|
1131 | + * @param int $width |
|
1132 | + * @param int $height |
|
1133 | + * @throws ImageHelper_Exception |
|
1134 | + * @return resource |
|
1135 | + */ |
|
1136 | 1136 | public function createNewImage(int $width, int $height) |
1137 | 1137 | { |
1138 | 1138 | $img = imagecreatetruecolor($width, $height); |
@@ -1156,38 +1156,38 @@ discard block |
||
1156 | 1156 | * @param int $y |
1157 | 1157 | * @return $this |
1158 | 1158 | */ |
1159 | - public function fillWhite(int $x=0, int $y=0) : self |
|
1160 | - { |
|
1161 | - $this->addRGBColor('white', 255, 255, 255); |
|
1159 | + public function fillWhite(int $x=0, int $y=0) : self |
|
1160 | + { |
|
1161 | + $this->addRGBColor('white', 255, 255, 255); |
|
1162 | 1162 | return $this->fill('white', $x, $y); |
1163 | - } |
|
1163 | + } |
|
1164 | 1164 | |
1165 | 1165 | /** |
1166 | 1166 | * @return $this |
1167 | 1167 | * @throws ImageHelper_Exception |
1168 | 1168 | */ |
1169 | - public function fillTransparent() : self |
|
1170 | - { |
|
1169 | + public function fillTransparent() : self |
|
1170 | + { |
|
1171 | 1171 | $this->enableAlpha(); |
1172 | 1172 | |
1173 | - self::fillImageTransparent($this->newImage); |
|
1173 | + self::fillImageTransparent($this->newImage); |
|
1174 | 1174 | |
1175 | - return $this; |
|
1176 | - } |
|
1175 | + return $this; |
|
1176 | + } |
|
1177 | 1177 | |
1178 | 1178 | /** |
1179 | 1179 | * @param resource $resource |
1180 | 1180 | * @return void |
1181 | 1181 | * @throws ImageHelper_Exception |
1182 | 1182 | */ |
1183 | - public static function fillImageTransparent($resource) : void |
|
1184 | - { |
|
1185 | - self::requireResource($resource); |
|
1183 | + public static function fillImageTransparent($resource) : void |
|
1184 | + { |
|
1185 | + self::requireResource($resource); |
|
1186 | 1186 | |
1187 | - $transparent = imagecolorallocatealpha($resource, 89, 14, 207, 127); |
|
1188 | - imagecolortransparent ($resource, $transparent); |
|
1189 | - imagefill($resource, 0, 0, $transparent); |
|
1190 | - } |
|
1187 | + $transparent = imagecolorallocatealpha($resource, 89, 14, 207, 127); |
|
1188 | + imagecolortransparent ($resource, $transparent); |
|
1189 | + imagefill($resource, 0, 0, $transparent); |
|
1190 | + } |
|
1191 | 1191 | |
1192 | 1192 | /** |
1193 | 1193 | * @param string $colorName |
@@ -1195,11 +1195,11 @@ discard block |
||
1195 | 1195 | * @param int $y |
1196 | 1196 | * @return $this |
1197 | 1197 | */ |
1198 | - public function fill(string $colorName, int $x=0, int $y=0) : self |
|
1199 | - { |
|
1200 | - imagefill($this->newImage, $x, $y, $this->colors[$colorName]); |
|
1201 | - return $this; |
|
1202 | - } |
|
1198 | + public function fill(string $colorName, int $x=0, int $y=0) : self |
|
1199 | + { |
|
1200 | + imagefill($this->newImage, $x, $y, $this->colors[$colorName]); |
|
1201 | + return $this; |
|
1202 | + } |
|
1203 | 1203 | |
1204 | 1204 | /** |
1205 | 1205 | * @param string $name |
@@ -1243,9 +1243,9 @@ discard block |
||
1243 | 1243 | return $this; |
1244 | 1244 | } |
1245 | 1245 | |
1246 | - /** |
|
1247 | - * @return resource |
|
1248 | - */ |
|
1246 | + /** |
|
1247 | + * @return resource |
|
1248 | + */ |
|
1249 | 1249 | public function getImage() |
1250 | 1250 | { |
1251 | 1251 | return $this->newImage; |
@@ -1293,17 +1293,17 @@ discard block |
||
1293 | 1293 | * |
1294 | 1294 | * @see ImageHelper::ERROR_CANNOT_GET_IMAGE_SIZE |
1295 | 1295 | */ |
1296 | - public function getSize() : ImageHelper_Size |
|
1296 | + public function getSize() : ImageHelper_Size |
|
1297 | 1297 | { |
1298 | - return self::getImageSize($this->newImage); |
|
1298 | + return self::getImageSize($this->newImage); |
|
1299 | 1299 | } |
1300 | 1300 | |
1301 | - /** |
|
1302 | - * Sets the TTF font file to use for text operations. |
|
1303 | - * |
|
1304 | - * @param string $filePath |
|
1305 | - * @return $this |
|
1306 | - */ |
|
1301 | + /** |
|
1302 | + * Sets the TTF font file to use for text operations. |
|
1303 | + * |
|
1304 | + * @param string $filePath |
|
1305 | + * @return $this |
|
1306 | + */ |
|
1307 | 1307 | public function setFontTTF(string $filePath) : self |
1308 | 1308 | { |
1309 | 1309 | $this->TTFFile = $filePath; |
@@ -1381,7 +1381,7 @@ discard block |
||
1381 | 1381 | return; |
1382 | 1382 | } |
1383 | 1383 | |
1384 | - throw new ImageHelper_Exception( |
|
1384 | + throw new ImageHelper_Exception( |
|
1385 | 1385 | 'No true type font specified', |
1386 | 1386 | 'This functionality requires a TTF font file to be specified with the [setFontTTF] method.', |
1387 | 1387 | self::ERROR_NO_TRUE_TYPE_FONT_SET |
@@ -1404,37 +1404,37 @@ discard block |
||
1404 | 1404 | * @see ImageHelper::ERROR_SVG_SOURCE_VIEWBOX_MISSING |
1405 | 1405 | * @see ImageHelper::ERROR_SVG_VIEWBOX_INVALID |
1406 | 1406 | */ |
1407 | - public static function getImageSize($pathOrResource) : ImageHelper_Size |
|
1408 | - { |
|
1409 | - if(is_resource($pathOrResource) || $pathOrResource instanceof GdImage) |
|
1410 | - { |
|
1411 | - return new ImageHelper_Size(array( |
|
1412 | - 'width' => imagesx($pathOrResource), |
|
1413 | - 'height' => imagesy($pathOrResource), |
|
1414 | - 'channels' => 1, |
|
1415 | - 'bits' => 8 |
|
1416 | - )); |
|
1417 | - } |
|
1407 | + public static function getImageSize($pathOrResource) : ImageHelper_Size |
|
1408 | + { |
|
1409 | + if(is_resource($pathOrResource) || $pathOrResource instanceof GdImage) |
|
1410 | + { |
|
1411 | + return new ImageHelper_Size(array( |
|
1412 | + 'width' => imagesx($pathOrResource), |
|
1413 | + 'height' => imagesy($pathOrResource), |
|
1414 | + 'channels' => 1, |
|
1415 | + 'bits' => 8 |
|
1416 | + )); |
|
1417 | + } |
|
1418 | 1418 | |
1419 | - $type = self::getFileImageType($pathOrResource); |
|
1419 | + $type = self::getFileImageType($pathOrResource); |
|
1420 | 1420 | |
1421 | 1421 | $sizeMethods = array( |
1422 | 1422 | 'svg' => array(self::class, 'getImageSize_svg') |
1423 | 1423 | ); |
1424 | 1424 | |
1425 | - if(isset($sizeMethods[$type])) |
|
1426 | - { |
|
1427 | - return ClassHelper::requireObjectInstanceOf( |
|
1425 | + if(isset($sizeMethods[$type])) |
|
1426 | + { |
|
1427 | + return ClassHelper::requireObjectInstanceOf( |
|
1428 | 1428 | ImageHelper_Size::class, |
1429 | 1429 | $sizeMethods[$type]($pathOrResource) |
1430 | 1430 | ); |
1431 | - } |
|
1431 | + } |
|
1432 | 1432 | |
1433 | - $info = getimagesize($pathOrResource); |
|
1433 | + $info = getimagesize($pathOrResource); |
|
1434 | 1434 | |
1435 | - if($info !== false) { |
|
1436 | - return new ImageHelper_Size($info); |
|
1437 | - } |
|
1435 | + if($info !== false) { |
|
1436 | + return new ImageHelper_Size($info); |
|
1437 | + } |
|
1438 | 1438 | |
1439 | 1439 | throw new ImageHelper_Exception( |
1440 | 1440 | 'Error opening image file', |
@@ -1444,7 +1444,7 @@ discard block |
||
1444 | 1444 | ), |
1445 | 1445 | self::ERROR_CANNOT_GET_IMAGE_SIZE |
1446 | 1446 | ); |
1447 | - } |
|
1447 | + } |
|
1448 | 1448 | |
1449 | 1449 | /** |
1450 | 1450 | * @param string $imagePath |
@@ -1454,78 +1454,78 @@ discard block |
||
1454 | 1454 | * @throws XMLHelper_Exception |
1455 | 1455 | * @throws JsonException |
1456 | 1456 | */ |
1457 | - protected static function getImageSize_svg(string $imagePath) : ImageHelper_Size |
|
1458 | - { |
|
1459 | - $xml = XMLHelper::createSimplexml(); |
|
1460 | - $xml->loadFile($imagePath); |
|
1457 | + protected static function getImageSize_svg(string $imagePath) : ImageHelper_Size |
|
1458 | + { |
|
1459 | + $xml = XMLHelper::createSimplexml(); |
|
1460 | + $xml->loadFile($imagePath); |
|
1461 | 1461 | |
1462 | - if($xml->hasErrors()) { |
|
1463 | - throw new ImageHelper_Exception( |
|
1464 | - 'Error opening SVG image', |
|
1465 | - sprintf( |
|
1466 | - 'The XML content of the image [%s] could not be parsed.', |
|
1467 | - $imagePath |
|
1462 | + if($xml->hasErrors()) { |
|
1463 | + throw new ImageHelper_Exception( |
|
1464 | + 'Error opening SVG image', |
|
1465 | + sprintf( |
|
1466 | + 'The XML content of the image [%s] could not be parsed.', |
|
1467 | + $imagePath |
|
1468 | 1468 | ), |
1469 | - self::ERROR_CANNOT_READ_SVG_IMAGE |
|
1469 | + self::ERROR_CANNOT_READ_SVG_IMAGE |
|
1470 | 1470 | ); |
1471 | - } |
|
1471 | + } |
|
1472 | 1472 | |
1473 | - $data = $xml->toArray(); |
|
1474 | - $xml->dispose(); |
|
1475 | - unset($xml); |
|
1473 | + $data = $xml->toArray(); |
|
1474 | + $xml->dispose(); |
|
1475 | + unset($xml); |
|
1476 | 1476 | |
1477 | - if(!isset($data['@attributes']['viewBox'])) { |
|
1478 | - throw new ImageHelper_Exception( |
|
1479 | - 'SVG Image is corrupted', |
|
1480 | - sprintf( |
|
1481 | - 'The [viewBox] attribute is missing in the XML of the image at path [%s].', |
|
1482 | - $imagePath |
|
1477 | + if(!isset($data['@attributes']['viewBox'])) { |
|
1478 | + throw new ImageHelper_Exception( |
|
1479 | + 'SVG Image is corrupted', |
|
1480 | + sprintf( |
|
1481 | + 'The [viewBox] attribute is missing in the XML of the image at path [%s].', |
|
1482 | + $imagePath |
|
1483 | 1483 | ), |
1484 | - self::ERROR_SVG_SOURCE_VIEWBOX_MISSING |
|
1484 | + self::ERROR_SVG_SOURCE_VIEWBOX_MISSING |
|
1485 | 1485 | ); |
1486 | - } |
|
1486 | + } |
|
1487 | 1487 | |
1488 | - $svgWidth = parseNumber($data['@attributes']['width'])->getNumber(); |
|
1489 | - $svgHeight = parseNumber($data['@attributes']['height'])->getNumber(); |
|
1488 | + $svgWidth = parseNumber($data['@attributes']['width'])->getNumber(); |
|
1489 | + $svgHeight = parseNumber($data['@attributes']['height'])->getNumber(); |
|
1490 | 1490 | |
1491 | - $viewBox = str_replace(' ', ',', $data['@attributes']['viewBox']); |
|
1492 | - $size = explode(',', $viewBox); |
|
1491 | + $viewBox = str_replace(' ', ',', $data['@attributes']['viewBox']); |
|
1492 | + $size = explode(',', $viewBox); |
|
1493 | 1493 | |
1494 | - if(count($size) !== 4) |
|
1495 | - { |
|
1496 | - throw new ImageHelper_Exception( |
|
1497 | - 'SVG image has an invalid viewBox attribute', |
|
1498 | - sprintf( |
|
1499 | - 'The [viewBox] attribute does not have an expected value: [%s] in path [%s].', |
|
1500 | - $viewBox, |
|
1501 | - $imagePath |
|
1494 | + if(count($size) !== 4) |
|
1495 | + { |
|
1496 | + throw new ImageHelper_Exception( |
|
1497 | + 'SVG image has an invalid viewBox attribute', |
|
1498 | + sprintf( |
|
1499 | + 'The [viewBox] attribute does not have an expected value: [%s] in path [%s].', |
|
1500 | + $viewBox, |
|
1501 | + $imagePath |
|
1502 | 1502 | ), |
1503 | - self::ERROR_SVG_VIEWBOX_INVALID |
|
1503 | + self::ERROR_SVG_VIEWBOX_INVALID |
|
1504 | 1504 | ); |
1505 | - } |
|
1505 | + } |
|
1506 | 1506 | |
1507 | - $boxWidth = (float)$size[2]; |
|
1508 | - $boxHeight = (float)$size[3]; |
|
1507 | + $boxWidth = (float)$size[2]; |
|
1508 | + $boxHeight = (float)$size[3]; |
|
1509 | 1509 | |
1510 | - // calculate the x and y units of the document: |
|
1511 | - // @see http://tutorials.jenkov.com/svg/svg-viewport-view-box.html#viewbox |
|
1512 | - // |
|
1513 | - // The viewbox combined with the width and height of the svg |
|
1514 | - // allow calculating how many pixels are in one unit of the |
|
1515 | - // width and height of the document. |
|
1510 | + // calculate the x and y units of the document: |
|
1511 | + // @see http://tutorials.jenkov.com/svg/svg-viewport-view-box.html#viewbox |
|
1516 | 1512 | // |
1517 | - $xUnits = $svgWidth / $boxWidth; |
|
1518 | - $yUnits = $svgHeight / $boxHeight; |
|
1513 | + // The viewbox combined with the width and height of the svg |
|
1514 | + // allow calculating how many pixels are in one unit of the |
|
1515 | + // width and height of the document. |
|
1516 | + // |
|
1517 | + $xUnits = $svgWidth / $boxWidth; |
|
1518 | + $yUnits = $svgHeight / $boxHeight; |
|
1519 | 1519 | |
1520 | - $pxWidth = $xUnits * $svgWidth; |
|
1521 | - $pxHeight = $yUnits * $svgHeight; |
|
1520 | + $pxWidth = $xUnits * $svgWidth; |
|
1521 | + $pxHeight = $yUnits * $svgHeight; |
|
1522 | 1522 | |
1523 | - return new ImageHelper_Size(array( |
|
1523 | + return new ImageHelper_Size(array( |
|
1524 | 1524 | (int)$pxWidth, |
1525 | 1525 | (int)$pxHeight, |
1526 | - 'bits' => 8 |
|
1527 | - )); |
|
1528 | - } |
|
1526 | + 'bits' => 8 |
|
1527 | + )); |
|
1528 | + } |
|
1529 | 1529 | |
1530 | 1530 | /** |
1531 | 1531 | * Crops the image to the specified width and height, optionally |
@@ -1584,26 +1584,26 @@ discard block |
||
1584 | 1584 | return $image->getColorAt(0, 0); |
1585 | 1585 | } |
1586 | 1586 | |
1587 | - /** |
|
1588 | - * Calculates the image's average color value, and |
|
1589 | - * returns an associative array with red, green, |
|
1590 | - * blue and alpha keys. |
|
1591 | - * |
|
1592 | - * @throws ImageHelper_Exception |
|
1593 | - * @return RGBAColor |
|
1594 | - */ |
|
1587 | + /** |
|
1588 | + * Calculates the image's average color value, and |
|
1589 | + * returns an associative array with red, green, |
|
1590 | + * blue and alpha keys. |
|
1591 | + * |
|
1592 | + * @throws ImageHelper_Exception |
|
1593 | + * @return RGBAColor |
|
1594 | + */ |
|
1595 | 1595 | public function calcAverageColorRGB() : RGBAColor |
1596 | 1596 | { |
1597 | - return $this->calcAverageColor(); |
|
1597 | + return $this->calcAverageColor(); |
|
1598 | 1598 | } |
1599 | 1599 | |
1600 | - /** |
|
1601 | - * Calculates the image's average color value, and |
|
1602 | - * returns a hex color string (without the #). |
|
1603 | - * |
|
1604 | - * @throws ImageHelper_Exception |
|
1605 | - * @return string |
|
1606 | - */ |
|
1600 | + /** |
|
1601 | + * Calculates the image's average color value, and |
|
1602 | + * returns a hex color string (without the #). |
|
1603 | + * |
|
1604 | + * @throws ImageHelper_Exception |
|
1605 | + * @return string |
|
1606 | + */ |
|
1607 | 1607 | public function calcAverageColorHex() : string |
1608 | 1608 | { |
1609 | 1609 | return $this->calcAverageColor()->toHEX(); |
@@ -1653,15 +1653,15 @@ discard block |
||
1653 | 1653 | return $this->calcAverageColorRGB()->getBrightness(); |
1654 | 1654 | } |
1655 | 1655 | |
1656 | - /** |
|
1657 | - * Retrieves a md5 hash of the source image file. |
|
1658 | - * |
|
1659 | - * NOTE: Only works when the helper has been created |
|
1660 | - * from a file. Otherwise, an exception is thrown. |
|
1661 | - * |
|
1662 | - * @return string |
|
1663 | - * @throws ImageHelper_Exception|OutputBuffering_Exception |
|
1664 | - */ |
|
1656 | + /** |
|
1657 | + * Retrieves a md5 hash of the source image file. |
|
1658 | + * |
|
1659 | + * NOTE: Only works when the helper has been created |
|
1660 | + * from a file. Otherwise, an exception is thrown. |
|
1661 | + * |
|
1662 | + * @return string |
|
1663 | + * @throws ImageHelper_Exception|OutputBuffering_Exception |
|
1664 | + */ |
|
1665 | 1665 | public function getHash() : string |
1666 | 1666 | { |
1667 | 1667 | if($this->newImage === null) |
@@ -73,18 +73,18 @@ discard block |
||
73 | 73 | public const ERROR_PATH_INVALID = 340040; |
74 | 74 | public const ERROR_CANNOT_COPY_FILE_TO_FOLDER = 340041; |
75 | 75 | |
76 | - /** |
|
77 | - * Opens a serialized file and returns the unserialized data. |
|
78 | - * |
|
79 | - * @param string|PathInfoInterface|SplFileInfo $file |
|
80 | - * @throws FileHelper_Exception |
|
81 | - * @return array<int|string,mixed> |
|
82 | - * @see SerializedFile::parse() |
|
83 | - * |
|
84 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
85 | - * @see FileHelper::ERROR_SERIALIZED_FILE_CANNOT_BE_READ |
|
86 | - * @see FileHelper::ERROR_SERIALIZED_FILE_UNSERIALZE_FAILED |
|
87 | - */ |
|
76 | + /** |
|
77 | + * Opens a serialized file and returns the unserialized data. |
|
78 | + * |
|
79 | + * @param string|PathInfoInterface|SplFileInfo $file |
|
80 | + * @throws FileHelper_Exception |
|
81 | + * @return array<int|string,mixed> |
|
82 | + * @see SerializedFile::parse() |
|
83 | + * |
|
84 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
85 | + * @see FileHelper::ERROR_SERIALIZED_FILE_CANNOT_BE_READ |
|
86 | + * @see FileHelper::ERROR_SERIALIZED_FILE_UNSERIALZE_FAILED |
|
87 | + */ |
|
88 | 88 | public static function parseSerializedFile($file) : array |
89 | 89 | { |
90 | 90 | return SerializedFile::factory($file)->parse(); |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | return FolderTree::delete($rootFolder); |
104 | 104 | } |
105 | 105 | |
106 | - /** |
|
107 | - * Create a folder, if it does not exist yet. |
|
108 | - * |
|
109 | - * @param string|PathInfoInterface $path |
|
110 | - * @throws FileHelper_Exception |
|
111 | - * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER |
|
112 | - */ |
|
106 | + /** |
|
107 | + * Create a folder, if it does not exist yet. |
|
108 | + * |
|
109 | + * @param string|PathInfoInterface $path |
|
110 | + * @throws FileHelper_Exception |
|
111 | + * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER |
|
112 | + */ |
|
113 | 113 | public static function createFolder($path) : FolderInfo |
114 | 114 | { |
115 | 115 | return self::getFolderInfo($path)->create(); |
@@ -138,36 +138,36 @@ discard block |
||
138 | 138 | FolderTree::copy($source, $target); |
139 | 139 | } |
140 | 140 | |
141 | - /** |
|
142 | - * Copies a file to the target location. Includes checks |
|
143 | - * for most error sources, like the source file not being |
|
144 | - * readable. Automatically creates the target folder if it |
|
145 | - * does not exist yet. |
|
146 | - * |
|
147 | - * @param string|PathInfoInterface|SplFileInfo $sourcePath |
|
148 | - * @param string|PathInfoInterface|SplFileInfo $targetPath |
|
149 | - * @throws FileHelper_Exception |
|
150 | - * |
|
151 | - * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER |
|
152 | - * @see FileHelper::ERROR_SOURCE_FILE_NOT_FOUND |
|
153 | - * @see FileHelper::ERROR_SOURCE_FILE_NOT_READABLE |
|
154 | - * @see FileHelper::ERROR_TARGET_COPY_FOLDER_NOT_WRITABLE |
|
155 | - * @see FileHelper::ERROR_CANNOT_COPY_FILE |
|
156 | - */ |
|
141 | + /** |
|
142 | + * Copies a file to the target location. Includes checks |
|
143 | + * for most error sources, like the source file not being |
|
144 | + * readable. Automatically creates the target folder if it |
|
145 | + * does not exist yet. |
|
146 | + * |
|
147 | + * @param string|PathInfoInterface|SplFileInfo $sourcePath |
|
148 | + * @param string|PathInfoInterface|SplFileInfo $targetPath |
|
149 | + * @throws FileHelper_Exception |
|
150 | + * |
|
151 | + * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER |
|
152 | + * @see FileHelper::ERROR_SOURCE_FILE_NOT_FOUND |
|
153 | + * @see FileHelper::ERROR_SOURCE_FILE_NOT_READABLE |
|
154 | + * @see FileHelper::ERROR_TARGET_COPY_FOLDER_NOT_WRITABLE |
|
155 | + * @see FileHelper::ERROR_CANNOT_COPY_FILE |
|
156 | + */ |
|
157 | 157 | public static function copyFile($sourcePath, $targetPath) : void |
158 | 158 | { |
159 | 159 | self::getFileInfo($sourcePath)->copyTo($targetPath); |
160 | 160 | } |
161 | 161 | |
162 | - /** |
|
163 | - * Deletes the target file. Ignored if it cannot be found, |
|
164 | - * and throws an exception if it fails. |
|
165 | - * |
|
166 | - * @param string|PathInfoInterface|SplFileInfo $filePath |
|
167 | - * @throws FileHelper_Exception |
|
168 | - * |
|
169 | - * @see FileHelper::ERROR_CANNOT_DELETE_FILE |
|
170 | - */ |
|
162 | + /** |
|
163 | + * Deletes the target file. Ignored if it cannot be found, |
|
164 | + * and throws an exception if it fails. |
|
165 | + * |
|
166 | + * @param string|PathInfoInterface|SplFileInfo $filePath |
|
167 | + * @throws FileHelper_Exception |
|
168 | + * |
|
169 | + * @see FileHelper::ERROR_CANNOT_DELETE_FILE |
|
170 | + */ |
|
171 | 171 | public static function deleteFile($filePath) : void |
172 | 172 | { |
173 | 173 | self::getFileInfo($filePath)->delete(); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | */ |
289 | 289 | public static function isPHPFile($filePath) : bool |
290 | 290 | { |
291 | - return self::getExtension($filePath) === 'php'; |
|
291 | + return self::getExtension($filePath) === 'php'; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -354,16 +354,16 @@ discard block |
||
354 | 354 | ->parse(); |
355 | 355 | } |
356 | 356 | |
357 | - /** |
|
358 | - * Corrects common formatting mistakes when users enter |
|
359 | - * file names, like too many spaces, dots and the like. |
|
360 | - * |
|
361 | - * NOTE: if the file name contains a path, the path is |
|
362 | - * stripped, leaving only the file name. |
|
363 | - * |
|
364 | - * @param string $name |
|
365 | - * @return string |
|
366 | - */ |
|
357 | + /** |
|
358 | + * Corrects common formatting mistakes when users enter |
|
359 | + * file names, like too many spaces, dots and the like. |
|
360 | + * |
|
361 | + * NOTE: if the file name contains a path, the path is |
|
362 | + * stripped, leaving only the file name. |
|
363 | + * |
|
364 | + * @param string $name |
|
365 | + * @return string |
|
366 | + */ |
|
367 | 367 | public static function fixFileName(string $name) : string |
368 | 368 | { |
369 | 369 | return NameFixer::fixName($name); |
@@ -423,23 +423,23 @@ discard block |
||
423 | 423 | return self::findFiles($targetFolder, array('php'), $options); |
424 | 424 | } |
425 | 425 | |
426 | - /** |
|
427 | - * Finds files according to the specified options. |
|
428 | - * |
|
429 | - * NOTE: This method only exists for backwards compatibility. |
|
430 | - * Use the {@see FileHelper::createFileFinder()} method instead, |
|
431 | - * which offers an object-oriented interface that is much easier |
|
432 | - * to use. |
|
433 | - * |
|
434 | - * @param string|PathInfoInterface|SplFileInfo $targetFolder |
|
435 | - * @param string[] $extensions |
|
436 | - * @param array<string,mixed> $options |
|
437 | - * @throws FileHelper_Exception |
|
438 | - * @return string[] |
|
439 | - * |
|
440 | - * @see FileHelper::createFileFinder() |
|
441 | - * @deprecated Use the file finder instead. |
|
442 | - */ |
|
426 | + /** |
|
427 | + * Finds files according to the specified options. |
|
428 | + * |
|
429 | + * NOTE: This method only exists for backwards compatibility. |
|
430 | + * Use the {@see FileHelper::createFileFinder()} method instead, |
|
431 | + * which offers an object-oriented interface that is much easier |
|
432 | + * to use. |
|
433 | + * |
|
434 | + * @param string|PathInfoInterface|SplFileInfo $targetFolder |
|
435 | + * @param string[] $extensions |
|
436 | + * @param array<string,mixed> $options |
|
437 | + * @throws FileHelper_Exception |
|
438 | + * @return string[] |
|
439 | + * |
|
440 | + * @see FileHelper::createFileFinder() |
|
441 | + * @deprecated Use the file finder instead. |
|
442 | + */ |
|
443 | 443 | public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array |
444 | 444 | { |
445 | 445 | $finder = self::createFileFinder($targetFolder); |
@@ -510,13 +510,13 @@ discard block |
||
510 | 510 | return self::$unicodeHandling; |
511 | 511 | } |
512 | 512 | |
513 | - /** |
|
514 | - * Normalizes the slash style in a file or folder path, |
|
515 | - * by replacing any anti-slashes with forward slashes. |
|
516 | - * |
|
517 | - * @param string $path |
|
518 | - * @return string |
|
519 | - */ |
|
513 | + /** |
|
514 | + * Normalizes the slash style in a file or folder path, |
|
515 | + * by replacing any anti-slashes with forward slashes. |
|
516 | + * |
|
517 | + * @param string $path |
|
518 | + * @return string |
|
519 | + */ |
|
520 | 520 | public static function normalizePath(string $path) : string |
521 | 521 | { |
522 | 522 | return str_replace(array('\\', '//'), array('/', '/'), $path); |
@@ -641,70 +641,70 @@ discard block |
||
641 | 641 | ->getPaths(); |
642 | 642 | } |
643 | 643 | |
644 | - /** |
|
645 | - * Retrieves the maximum allowed upload file size, in bytes. |
|
646 | - * Takes into account the PHP ini settings <code>post_max_size</code> |
|
647 | - * and <code>upload_max_filesize</code>. Since these cannot |
|
648 | - * be modified at runtime, they are the hard limits for uploads. |
|
649 | - * |
|
650 | - * NOTE: Based on binary values, where 1KB = 1024 Bytes. |
|
651 | - * |
|
652 | - * @return int Will return <code>-1</code> if no limit. |
|
653 | - */ |
|
644 | + /** |
|
645 | + * Retrieves the maximum allowed upload file size, in bytes. |
|
646 | + * Takes into account the PHP ini settings <code>post_max_size</code> |
|
647 | + * and <code>upload_max_filesize</code>. Since these cannot |
|
648 | + * be modified at runtime, they are the hard limits for uploads. |
|
649 | + * |
|
650 | + * NOTE: Based on binary values, where 1KB = 1024 Bytes. |
|
651 | + * |
|
652 | + * @return int Will return <code>-1</code> if no limit. |
|
653 | + */ |
|
654 | 654 | public static function getMaxUploadFilesize() : int |
655 | 655 | { |
656 | 656 | return UploadFileSizeInfo::getFileSize(); |
657 | 657 | } |
658 | 658 | |
659 | - /** |
|
660 | - * Makes a path relative using a folder depth: will reduce the |
|
661 | - * length of the path so that only the amount of folders defined |
|
662 | - * in the <code>$depth</code> attribute are shown below the actual |
|
663 | - * folder or file in the path. |
|
664 | - * |
|
665 | - * @param string $path The absolute or relative path |
|
666 | - * @param int $depth The folder depth to reduce the path to |
|
667 | - * @return string |
|
668 | - */ |
|
659 | + /** |
|
660 | + * Makes a path relative using a folder depth: will reduce the |
|
661 | + * length of the path so that only the amount of folders defined |
|
662 | + * in the <code>$depth</code> attribute are shown below the actual |
|
663 | + * folder or file in the path. |
|
664 | + * |
|
665 | + * @param string $path The absolute or relative path |
|
666 | + * @param int $depth The folder depth to reduce the path to |
|
667 | + * @return string |
|
668 | + */ |
|
669 | 669 | public static function relativizePathByDepth(string $path, int $depth=2) : string |
670 | 670 | { |
671 | 671 | return PathRelativizer::relativizeByDepth($path, $depth); |
672 | 672 | } |
673 | 673 | |
674 | - /** |
|
675 | - * Makes the specified path relative to another path, |
|
676 | - * by removing one from the other if found. Also |
|
677 | - * normalizes the path to use forward slashes. |
|
678 | - * |
|
679 | - * Example: |
|
680 | - * |
|
681 | - * <pre> |
|
682 | - * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder'); |
|
683 | - * </pre> |
|
684 | - * |
|
685 | - * Result: <code>to/file.txt</code> |
|
686 | - * |
|
687 | - * @param string $path |
|
688 | - * @param string $relativeTo |
|
689 | - * @return string |
|
690 | - */ |
|
674 | + /** |
|
675 | + * Makes the specified path relative to another path, |
|
676 | + * by removing one from the other if found. Also |
|
677 | + * normalizes the path to use forward slashes. |
|
678 | + * |
|
679 | + * Example: |
|
680 | + * |
|
681 | + * <pre> |
|
682 | + * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder'); |
|
683 | + * </pre> |
|
684 | + * |
|
685 | + * Result: <code>to/file.txt</code> |
|
686 | + * |
|
687 | + * @param string $path |
|
688 | + * @param string $relativeTo |
|
689 | + * @return string |
|
690 | + */ |
|
691 | 691 | public static function relativizePath(string $path, string $relativeTo) : string |
692 | 692 | { |
693 | 693 | return PathRelativizer::relativize($path, $relativeTo); |
694 | 694 | } |
695 | 695 | |
696 | - /** |
|
697 | - * Checks that the target file exists, and throws an exception |
|
698 | - * if it does not. |
|
699 | - * |
|
700 | - * @param string|SplFileInfo $path |
|
701 | - * @param int|NULL $errorCode Optional custom error code |
|
702 | - * @throws FileHelper_Exception |
|
703 | - * @return string The real path to the file |
|
704 | - * |
|
705 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
706 | - * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND |
|
707 | - */ |
|
696 | + /** |
|
697 | + * Checks that the target file exists, and throws an exception |
|
698 | + * if it does not. |
|
699 | + * |
|
700 | + * @param string|SplFileInfo $path |
|
701 | + * @param int|NULL $errorCode Optional custom error code |
|
702 | + * @throws FileHelper_Exception |
|
703 | + * @return string The real path to the file |
|
704 | + * |
|
705 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
706 | + * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND |
|
707 | + */ |
|
708 | 708 | public static function requireFileExists($path, ?int $errorCode=null) : string |
709 | 709 | { |
710 | 710 | return self::getPathInfo($path) |
@@ -727,18 +727,18 @@ discard block |
||
727 | 727 | ->getPath(); |
728 | 728 | } |
729 | 729 | |
730 | - /** |
|
731 | - * Reads a specific line number from the target file and returns its |
|
732 | - * contents, if the file has such a line. Does so with little memory |
|
733 | - * usage, as the file is not read entirely into memory. |
|
734 | - * |
|
735 | - * @param string|PathInfoInterface|SplFileInfo $path |
|
736 | - * @param int $lineNumber Note: 1-based; the first line is number 1. |
|
737 | - * @return string|NULL Will return null if the requested line does not exist. |
|
738 | - * @throws FileHelper_Exception |
|
739 | - * |
|
740 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
741 | - */ |
|
730 | + /** |
|
731 | + * Reads a specific line number from the target file and returns its |
|
732 | + * contents, if the file has such a line. Does so with little memory |
|
733 | + * usage, as the file is not read entirely into memory. |
|
734 | + * |
|
735 | + * @param string|PathInfoInterface|SplFileInfo $path |
|
736 | + * @param int $lineNumber Note: 1-based; the first line is number 1. |
|
737 | + * @return string|NULL Will return null if the requested line does not exist. |
|
738 | + * @throws FileHelper_Exception |
|
739 | + * |
|
740 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
741 | + */ |
|
742 | 742 | public static function getLineFromFile($path, int $lineNumber) : ?string |
743 | 743 | { |
744 | 744 | return self::getFileInfo($path)->getLine($lineNumber); |
@@ -804,33 +804,33 @@ discard block |
||
804 | 804 | ->getLines($amount); |
805 | 805 | } |
806 | 806 | |
807 | - /** |
|
808 | - * Reads all content from a file. |
|
809 | - * |
|
810 | - * @param string|PathInfoInterface|SplFileInfo $filePath |
|
811 | - * @throws FileHelper_Exception |
|
812 | - * @return string |
|
813 | - * |
|
814 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
815 | - * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
816 | - */ |
|
807 | + /** |
|
808 | + * Reads all content from a file. |
|
809 | + * |
|
810 | + * @param string|PathInfoInterface|SplFileInfo $filePath |
|
811 | + * @throws FileHelper_Exception |
|
812 | + * @return string |
|
813 | + * |
|
814 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
815 | + * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
816 | + */ |
|
817 | 817 | public static function readContents($filePath) : string |
818 | 818 | { |
819 | 819 | return self::getFileInfo($filePath)->getContents(); |
820 | 820 | } |
821 | 821 | |
822 | - /** |
|
823 | - * Ensures that the target path exists on disk, and is a folder. |
|
824 | - * |
|
825 | - * @param string|PathInfoInterface|SplFileInfo $path |
|
826 | - * @return string The real path, with normalized slashes. |
|
827 | - * @throws FileHelper_Exception |
|
828 | - * |
|
829 | - * @see FileHelper::normalizePath() |
|
830 | - * |
|
831 | - * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST |
|
832 | - * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER |
|
833 | - */ |
|
822 | + /** |
|
823 | + * Ensures that the target path exists on disk, and is a folder. |
|
824 | + * |
|
825 | + * @param string|PathInfoInterface|SplFileInfo $path |
|
826 | + * @return string The real path, with normalized slashes. |
|
827 | + * @throws FileHelper_Exception |
|
828 | + * |
|
829 | + * @see FileHelper::normalizePath() |
|
830 | + * |
|
831 | + * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST |
|
832 | + * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER |
|
833 | + */ |
|
834 | 834 | public static function requireFolderExists($path) : string |
835 | 835 | { |
836 | 836 | return self::getFolderInfo($path) |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | return ConvertHelper_String::tabs2spaces($string, $tabSize); |
67 | 67 | } |
68 | 68 | |
69 | - /** |
|
70 | - * Converts spaces to tabs in the specified string. |
|
71 | - * |
|
72 | - * @param string $string |
|
73 | - * @param int $tabSize The amount of spaces per tab in the source string. |
|
74 | - * @return string |
|
75 | - */ |
|
69 | + /** |
|
70 | + * Converts spaces to tabs in the specified string. |
|
71 | + * |
|
72 | + * @param string $string |
|
73 | + * @param int $tabSize The amount of spaces per tab in the source string. |
|
74 | + * @return string |
|
75 | + */ |
|
76 | 76 | public static function spaces2tabs(string $string, int $tabSize=4) : string |
77 | 77 | { |
78 | 78 | return ConvertHelper_String::spaces2tabs($string, $tabSize); |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | return ConvertHelper_String::hidden2visible($string); |
91 | 91 | } |
92 | 92 | |
93 | - /** |
|
94 | - * Converts the specified amount of seconds into |
|
95 | - * a human-readable string split in months, weeks, |
|
96 | - * days, hours, minutes and seconds. |
|
97 | - * |
|
98 | - * @param float $seconds |
|
99 | - * @return string |
|
100 | - */ |
|
93 | + /** |
|
94 | + * Converts the specified amount of seconds into |
|
95 | + * a human-readable string split in months, weeks, |
|
96 | + * days, hours, minutes and seconds. |
|
97 | + * |
|
98 | + * @param float $seconds |
|
99 | + * @return string |
|
100 | + */ |
|
101 | 101 | public static function time2string($seconds) : string |
102 | 102 | { |
103 | 103 | $converter = new ConvertHelper_TimeConverter($seconds); |
@@ -121,85 +121,85 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function duration2string($datefrom, $dateto = -1) : string |
123 | 123 | { |
124 | - return ConvertHelper_DurationConverter::toString($datefrom, $dateto); |
|
124 | + return ConvertHelper_DurationConverter::toString($datefrom, $dateto); |
|
125 | 125 | } |
126 | 126 | |
127 | - /** |
|
128 | - * Adds HTML syntax highlighting to the specified SQL string. |
|
129 | - * |
|
130 | - * @param string $sql |
|
131 | - * @return string |
|
132 | - * @deprecated Use the Highlighter class directly instead. |
|
133 | - * @see Highlighter::sql() |
|
134 | - */ |
|
127 | + /** |
|
128 | + * Adds HTML syntax highlighting to the specified SQL string. |
|
129 | + * |
|
130 | + * @param string $sql |
|
131 | + * @return string |
|
132 | + * @deprecated Use the Highlighter class directly instead. |
|
133 | + * @see Highlighter::sql() |
|
134 | + */ |
|
135 | 135 | public static function highlight_sql(string $sql) : string |
136 | 136 | { |
137 | 137 | return Highlighter::sql($sql); |
138 | 138 | } |
139 | 139 | |
140 | - /** |
|
141 | - * Adds HTML syntax highlighting to the specified XML code. |
|
142 | - * |
|
143 | - * @param string $xml The XML to highlight. |
|
144 | - * @param bool $formatSource Whether to format the source with indentation to make it readable. |
|
145 | - * @return string |
|
146 | - * @deprecated Use the Highlighter class directly instead. |
|
147 | - * @see Highlighter::xml() |
|
148 | - */ |
|
140 | + /** |
|
141 | + * Adds HTML syntax highlighting to the specified XML code. |
|
142 | + * |
|
143 | + * @param string $xml The XML to highlight. |
|
144 | + * @param bool $formatSource Whether to format the source with indentation to make it readable. |
|
145 | + * @return string |
|
146 | + * @deprecated Use the Highlighter class directly instead. |
|
147 | + * @see Highlighter::xml() |
|
148 | + */ |
|
149 | 149 | public static function highlight_xml(string $xml, bool $formatSource=false) : string |
150 | 150 | { |
151 | 151 | return Highlighter::xml($xml, $formatSource); |
152 | 152 | } |
153 | 153 | |
154 | - /** |
|
155 | - * @param string $phpCode |
|
156 | - * @return string |
|
157 | - * @deprecated Use the Highlighter class directly instead. |
|
158 | - * @see Highlighter::php() |
|
159 | - */ |
|
154 | + /** |
|
155 | + * @param string $phpCode |
|
156 | + * @return string |
|
157 | + * @deprecated Use the Highlighter class directly instead. |
|
158 | + * @see Highlighter::php() |
|
159 | + */ |
|
160 | 160 | public static function highlight_php(string $phpCode) : string |
161 | 161 | { |
162 | 162 | return Highlighter::php($phpCode); |
163 | 163 | } |
164 | 164 | |
165 | - /** |
|
166 | - * Converts a number of bytes to a human-readable form, |
|
167 | - * e.g. xx Kb / xx Mb / xx Gb |
|
168 | - * |
|
169 | - * @param int $bytes The amount of bytes to convert. |
|
170 | - * @param int $precision The amount of decimals |
|
171 | - * @param int $base The base to calculate with: Base 10 is default (=1000 Bytes in a KB), Base 2 is mainly used for Windows memory (=1024 Bytes in a KB). |
|
172 | - * @return string |
|
173 | - * |
|
174 | - * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions |
|
175 | - */ |
|
165 | + /** |
|
166 | + * Converts a number of bytes to a human-readable form, |
|
167 | + * e.g. xx Kb / xx Mb / xx Gb |
|
168 | + * |
|
169 | + * @param int $bytes The amount of bytes to convert. |
|
170 | + * @param int $precision The amount of decimals |
|
171 | + * @param int $base The base to calculate with: Base 10 is default (=1000 Bytes in a KB), Base 2 is mainly used for Windows memory (=1024 Bytes in a KB). |
|
172 | + * @return string |
|
173 | + * |
|
174 | + * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions |
|
175 | + */ |
|
176 | 176 | public static function bytes2readable(int $bytes, int $precision = 1, int $base = ConvertHelper_StorageSizeEnum::BASE_10) : string |
177 | 177 | { |
178 | 178 | return self::parseBytes($bytes)->toString($precision, $base); |
179 | 179 | } |
180 | 180 | |
181 | - /** |
|
182 | - * Parses a number of bytes, and creates a converter instance which |
|
183 | - * allows doing common operations with it. |
|
184 | - * |
|
185 | - * @param int $bytes |
|
186 | - * @return ConvertHelper_ByteConverter |
|
187 | - */ |
|
181 | + /** |
|
182 | + * Parses a number of bytes, and creates a converter instance which |
|
183 | + * allows doing common operations with it. |
|
184 | + * |
|
185 | + * @param int $bytes |
|
186 | + * @return ConvertHelper_ByteConverter |
|
187 | + */ |
|
188 | 188 | public static function parseBytes(int $bytes) : ConvertHelper_ByteConverter |
189 | 189 | { |
190 | 190 | return new ConvertHelper_ByteConverter($bytes); |
191 | 191 | } |
192 | 192 | |
193 | - /** |
|
194 | - * Cuts a text to the specified length if it is longer than the |
|
195 | - * target length. Appends a text to signify it has been cut at |
|
196 | - * the end of the string. |
|
197 | - * |
|
198 | - * @param string $text |
|
199 | - * @param int $targetLength |
|
200 | - * @param string $append |
|
201 | - * @return string |
|
202 | - */ |
|
193 | + /** |
|
194 | + * Cuts a text to the specified length if it is longer than the |
|
195 | + * target length. Appends a text to signify it has been cut at |
|
196 | + * the end of the string. |
|
197 | + * |
|
198 | + * @param string $text |
|
199 | + * @param int $targetLength |
|
200 | + * @param string $append |
|
201 | + * @return string |
|
202 | + */ |
|
203 | 203 | public static function text_cut(string $text, int $targetLength, string $append = '...') : string |
204 | 204 | { |
205 | 205 | return ConvertHelper_String::cutText($text, $targetLength, $append); |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | return $info->toString(); |
224 | 224 | } |
225 | 225 | |
226 | - /** |
|
227 | - * Pretty `print_r`. |
|
228 | - * |
|
229 | - * @param mixed $var The variable to dump. |
|
230 | - * @param bool $return Whether to return the dumped code. |
|
231 | - * @param bool $html Whether to style the dump as HTML. |
|
232 | - * @return string |
|
233 | - */ |
|
226 | + /** |
|
227 | + * Pretty `print_r`. |
|
228 | + * |
|
229 | + * @param mixed $var The variable to dump. |
|
230 | + * @param bool $return Whether to return the dumped code. |
|
231 | + * @param bool $html Whether to style the dump as HTML. |
|
232 | + * @return string |
|
233 | + */ |
|
234 | 234 | public static function print_r($var, bool $return=false, bool $html=true) : string |
235 | 235 | { |
236 | 236 | $result = parseVariable($var)->enableType()->toString(); |
@@ -251,29 +251,29 @@ discard block |
||
251 | 251 | return $result; |
252 | 252 | } |
253 | 253 | |
254 | - /** |
|
255 | - * Converts a string, number or boolean value to a boolean value. |
|
256 | - * |
|
257 | - * @param mixed $string |
|
258 | - * @throws ConvertHelper_Exception |
|
259 | - * @return bool |
|
260 | - * |
|
261 | - * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING |
|
262 | - */ |
|
254 | + /** |
|
255 | + * Converts a string, number or boolean value to a boolean value. |
|
256 | + * |
|
257 | + * @param mixed $string |
|
258 | + * @throws ConvertHelper_Exception |
|
259 | + * @return bool |
|
260 | + * |
|
261 | + * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING |
|
262 | + */ |
|
263 | 263 | public static function string2bool($string) : bool |
264 | 264 | { |
265 | 265 | return ConvertHelper_Bool::fromString($string); |
266 | 266 | } |
267 | 267 | |
268 | - /** |
|
269 | - * Whether the specified string is a boolean string or boolean value. |
|
270 | - * Alias for {@link ConvertHelper::isBoolean()}. |
|
271 | - * |
|
272 | - * @param mixed $string |
|
273 | - * @return bool |
|
274 | - * @deprecated |
|
275 | - * @see ConvertHelper::isBoolean() |
|
276 | - */ |
|
268 | + /** |
|
269 | + * Whether the specified string is a boolean string or boolean value. |
|
270 | + * Alias for {@link ConvertHelper::isBoolean()}. |
|
271 | + * |
|
272 | + * @param mixed $string |
|
273 | + * @return bool |
|
274 | + * @deprecated |
|
275 | + * @see ConvertHelper::isBoolean() |
|
276 | + */ |
|
277 | 277 | public static function isBooleanString($string) : bool |
278 | 278 | { |
279 | 279 | return self::isBoolean($string); |
@@ -343,36 +343,36 @@ discard block |
||
343 | 343 | return ConvertHelper_String::transliterate($string, $spaceChar, $lowercase); |
344 | 344 | } |
345 | 345 | |
346 | - /** |
|
347 | - * Retrieves the HEX character codes for all control |
|
348 | - * characters that the {@link stripControlCharacters()} |
|
349 | - * method will remove. |
|
350 | - * |
|
351 | - * @return string[] |
|
352 | - */ |
|
346 | + /** |
|
347 | + * Retrieves the HEX character codes for all control |
|
348 | + * characters that the {@link stripControlCharacters()} |
|
349 | + * method will remove. |
|
350 | + * |
|
351 | + * @return string[] |
|
352 | + */ |
|
353 | 353 | public static function getControlCharactersAsHex() : array |
354 | 354 | { |
355 | 355 | return self::createControlCharacters()->getCharsAsHex(); |
356 | 356 | } |
357 | 357 | |
358 | - /** |
|
359 | - * Retrieves an array of all control characters that |
|
360 | - * the {@link stripControlCharacters()} method will |
|
361 | - * remove, as the actual UTF-8 characters. |
|
362 | - * |
|
363 | - * @return string[] |
|
364 | - */ |
|
358 | + /** |
|
359 | + * Retrieves an array of all control characters that |
|
360 | + * the {@link stripControlCharacters()} method will |
|
361 | + * remove, as the actual UTF-8 characters. |
|
362 | + * |
|
363 | + * @return string[] |
|
364 | + */ |
|
365 | 365 | public static function getControlCharactersAsUTF8() : array |
366 | 366 | { |
367 | 367 | return self::createControlCharacters()->getCharsAsUTF8(); |
368 | 368 | } |
369 | 369 | |
370 | - /** |
|
371 | - * Retrieves all control characters as JSON encoded |
|
372 | - * characters, e.g. "\u200b". |
|
373 | - * |
|
374 | - * @return string[] |
|
375 | - */ |
|
370 | + /** |
|
371 | + * Retrieves all control characters as JSON encoded |
|
372 | + * characters, e.g. "\u200b". |
|
373 | + * |
|
374 | + * @return string[] |
|
375 | + */ |
|
376 | 376 | public static function getControlCharactersAsJSON() : array |
377 | 377 | { |
378 | 378 | return self::createControlCharacters()->getCharsAsJSON(); |
@@ -393,31 +393,31 @@ discard block |
||
393 | 393 | return self::createControlCharacters()->stripControlCharacters($string); |
394 | 394 | } |
395 | 395 | |
396 | - /** |
|
397 | - * Creates the control characters class, used to |
|
398 | - * work with control characters in strings. |
|
399 | - * |
|
400 | - * @return ConvertHelper_ControlCharacters |
|
401 | - */ |
|
396 | + /** |
|
397 | + * Creates the control characters class, used to |
|
398 | + * work with control characters in strings. |
|
399 | + * |
|
400 | + * @return ConvertHelper_ControlCharacters |
|
401 | + */ |
|
402 | 402 | public static function createControlCharacters() : ConvertHelper_ControlCharacters |
403 | 403 | { |
404 | 404 | return new ConvertHelper_ControlCharacters(); |
405 | 405 | } |
406 | 406 | |
407 | - /** |
|
408 | - * Converts a unicode character to the PHP notation. |
|
409 | - * |
|
410 | - * Example: |
|
411 | - * |
|
412 | - * <pre>unicodeChar2php('"\u0000"')</pre> |
|
413 | - * |
|
414 | - * Returns |
|
415 | - * |
|
416 | - * <pre>\x0</pre> |
|
417 | - * |
|
418 | - * @param string $unicodeChar |
|
419 | - * @return string |
|
420 | - */ |
|
407 | + /** |
|
408 | + * Converts a unicode character to the PHP notation. |
|
409 | + * |
|
410 | + * Example: |
|
411 | + * |
|
412 | + * <pre>unicodeChar2php('"\u0000"')</pre> |
|
413 | + * |
|
414 | + * Returns |
|
415 | + * |
|
416 | + * <pre>\x0</pre> |
|
417 | + * |
|
418 | + * @param string $unicodeChar |
|
419 | + * @return string |
|
420 | + */ |
|
421 | 421 | public static function unicodeChar2php(string $unicodeChar) : string |
422 | 422 | { |
423 | 423 | $unicodeChar = json_decode($unicodeChar); |
@@ -531,25 +531,25 @@ discard block |
||
531 | 531 | return ConvertHelper_Bool::toStringStrict($boolean, $yesNo); |
532 | 532 | } |
533 | 533 | |
534 | - /** |
|
535 | - * Converts an associative array with attribute name > value pairs |
|
536 | - * to an attribute string that can be used in an HTML tag. Empty |
|
537 | - * attribute values are ignored. |
|
538 | - * |
|
539 | - * Example: |
|
540 | - * |
|
541 | - * array2attributeString(array( |
|
542 | - * 'id' => 45, |
|
543 | - * 'href' => 'http://www.mistralys.com' |
|
544 | - * )); |
|
545 | - * |
|
546 | - * Result: |
|
547 | - * |
|
548 | - * id="45" href="http://www.mistralys.com" |
|
549 | - * |
|
550 | - * @param array<string,mixed> $array |
|
551 | - * @return string |
|
552 | - */ |
|
534 | + /** |
|
535 | + * Converts an associative array with attribute name > value pairs |
|
536 | + * to an attribute string that can be used in an HTML tag. Empty |
|
537 | + * attribute values are ignored. |
|
538 | + * |
|
539 | + * Example: |
|
540 | + * |
|
541 | + * array2attributeString(array( |
|
542 | + * 'id' => 45, |
|
543 | + * 'href' => 'http://www.mistralys.com' |
|
544 | + * )); |
|
545 | + * |
|
546 | + * Result: |
|
547 | + * |
|
548 | + * id="45" href="http://www.mistralys.com" |
|
549 | + * |
|
550 | + * @param array<string,mixed> $array |
|
551 | + * @return string |
|
552 | + */ |
|
553 | 553 | public static function array2attributeString(array $array) : string |
554 | 554 | { |
555 | 555 | return ConvertHelper_Array::toAttributeString($array); |
@@ -569,116 +569,116 @@ discard block |
||
569 | 569 | return self::var2json($array); |
570 | 570 | } |
571 | 571 | |
572 | - /** |
|
573 | - * Converts a string, so it can safely be used in a javascript |
|
574 | - * statement in an HTML tag: uses single quotes around the string |
|
575 | - * and encodes all special characters as needed. |
|
576 | - * |
|
577 | - * @param string $string |
|
578 | - * @return string |
|
579 | - * @deprecated Use the JSHelper class instead. |
|
580 | - * @see JSHelper::phpVariable2AttributeJS() |
|
581 | - */ |
|
572 | + /** |
|
573 | + * Converts a string, so it can safely be used in a javascript |
|
574 | + * statement in an HTML tag: uses single quotes around the string |
|
575 | + * and encodes all special characters as needed. |
|
576 | + * |
|
577 | + * @param string $string |
|
578 | + * @return string |
|
579 | + * @deprecated Use the JSHelper class instead. |
|
580 | + * @see JSHelper::phpVariable2AttributeJS() |
|
581 | + */ |
|
582 | 582 | public static function string2attributeJS(string $string) : string |
583 | 583 | { |
584 | 584 | return JSHelper::phpVariable2AttributeJS($string); |
585 | 585 | } |
586 | 586 | |
587 | - /** |
|
588 | - * Checks if the specified string is a boolean value, which |
|
589 | - * includes string representations of boolean values, like |
|
590 | - * <code>yes</code> or <code>no</code>, and <code>true</code> |
|
591 | - * or <code>false</code>. |
|
592 | - * |
|
593 | - * @param mixed $value |
|
594 | - * @return boolean |
|
595 | - */ |
|
587 | + /** |
|
588 | + * Checks if the specified string is a boolean value, which |
|
589 | + * includes string representations of boolean values, like |
|
590 | + * <code>yes</code> or <code>no</code>, and <code>true</code> |
|
591 | + * or <code>false</code>. |
|
592 | + * |
|
593 | + * @param mixed $value |
|
594 | + * @return boolean |
|
595 | + */ |
|
596 | 596 | public static function isBoolean($value) : bool |
597 | 597 | { |
598 | 598 | return ConvertHelper_Bool::isBoolean($value); |
599 | 599 | } |
600 | 600 | |
601 | - /** |
|
602 | - * Converts an associative array to an HTML style attribute value string. |
|
603 | - * |
|
604 | - * @param array<string,mixed> $subject |
|
605 | - * @return string |
|
606 | - */ |
|
601 | + /** |
|
602 | + * Converts an associative array to an HTML style attribute value string. |
|
603 | + * |
|
604 | + * @param array<string,mixed> $subject |
|
605 | + * @return string |
|
606 | + */ |
|
607 | 607 | public static function array2styleString(array $subject) : string |
608 | 608 | { |
609 | 609 | return ConvertHelper_Array::toStyleString($subject); |
610 | 610 | } |
611 | 611 | |
612 | - /** |
|
613 | - * Converts a DateTime object to a timestamp, which |
|
614 | - * is PHP 5.2 compatible. |
|
615 | - * |
|
616 | - * @param DateTime $date |
|
617 | - * @return integer |
|
618 | - */ |
|
612 | + /** |
|
613 | + * Converts a DateTime object to a timestamp, which |
|
614 | + * is PHP 5.2 compatible. |
|
615 | + * |
|
616 | + * @param DateTime $date |
|
617 | + * @return integer |
|
618 | + */ |
|
619 | 619 | public static function date2timestamp(DateTime $date) : int |
620 | 620 | { |
621 | 621 | return ConvertHelper_Date::toTimestamp($date); |
622 | 622 | } |
623 | 623 | |
624 | - /** |
|
625 | - * Converts a timestamp into a DateTime instance. |
|
626 | - * @param int $timestamp |
|
627 | - * @return DateTime |
|
628 | - */ |
|
624 | + /** |
|
625 | + * Converts a timestamp into a DateTime instance. |
|
626 | + * @param int $timestamp |
|
627 | + * @return DateTime |
|
628 | + */ |
|
629 | 629 | public static function timestamp2date(int $timestamp) : DateTime |
630 | 630 | { |
631 | 631 | return ConvertHelper_Date::fromTimestamp($timestamp); |
632 | 632 | } |
633 | 633 | |
634 | - /** |
|
635 | - * Strips an absolute path to a file within the application |
|
636 | - * to make the path relative to the application root path. |
|
637 | - * |
|
638 | - * @param string $path |
|
639 | - * @return string |
|
640 | - * |
|
641 | - * @see FileHelper::relativizePath() |
|
642 | - * @see FileHelper::relativizePathByDepth() |
|
643 | - */ |
|
634 | + /** |
|
635 | + * Strips an absolute path to a file within the application |
|
636 | + * to make the path relative to the application root path. |
|
637 | + * |
|
638 | + * @param string $path |
|
639 | + * @return string |
|
640 | + * |
|
641 | + * @see FileHelper::relativizePath() |
|
642 | + * @see FileHelper::relativizePathByDepth() |
|
643 | + */ |
|
644 | 644 | public static function fileRelativize(string $path) : string |
645 | 645 | { |
646 | 646 | return FileHelper::relativizePathByDepth($path); |
647 | 647 | } |
648 | 648 | |
649 | 649 | /** |
650 | - * Converts a PHP regex to a javascript RegExp object statement. |
|
651 | - * |
|
652 | - * NOTE: This is an alias for the JSHelper's `convertRegex` method. |
|
653 | - * More details are available on its usage there. |
|
654 | - * |
|
655 | - * @param string $regex A PHP preg regex |
|
656 | - * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object. |
|
657 | - * @return string Depending on the specified return type. |
|
658 | - * |
|
659 | - * @see JSHelper::buildRegexStatement() |
|
660 | - */ |
|
650 | + * Converts a PHP regex to a javascript RegExp object statement. |
|
651 | + * |
|
652 | + * NOTE: This is an alias for the JSHelper's `convertRegex` method. |
|
653 | + * More details are available on its usage there. |
|
654 | + * |
|
655 | + * @param string $regex A PHP preg regex |
|
656 | + * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object. |
|
657 | + * @return string Depending on the specified return type. |
|
658 | + * |
|
659 | + * @see JSHelper::buildRegexStatement() |
|
660 | + */ |
|
661 | 661 | public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) : string |
662 | 662 | { |
663 | 663 | return JSHelper::buildRegexStatement($regex, $statementType); |
664 | 664 | } |
665 | 665 | |
666 | - /** |
|
667 | - * Converts the specified variable to a JSON string. |
|
668 | - * |
|
669 | - * Works just like the native `json_encode` method, |
|
670 | - * except that it will trigger an exception on failure, |
|
671 | - * which has the json error details included in its |
|
672 | - * developer details. |
|
673 | - * |
|
674 | - * @param mixed $variable |
|
675 | - * @param int $options JSON encode options. |
|
676 | - * @param int $depth |
|
677 | - * @return string |
|
678 | - * |
|
679 | - * @throws JSONConverterException |
|
680 | - * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED |
|
681 | - */ |
|
666 | + /** |
|
667 | + * Converts the specified variable to a JSON string. |
|
668 | + * |
|
669 | + * Works just like the native `json_encode` method, |
|
670 | + * except that it will trigger an exception on failure, |
|
671 | + * which has the json error details included in its |
|
672 | + * developer details. |
|
673 | + * |
|
674 | + * @param mixed $variable |
|
675 | + * @param int $options JSON encode options. |
|
676 | + * @param int $depth |
|
677 | + * @return string |
|
678 | + * |
|
679 | + * @throws JSONConverterException |
|
680 | + * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED |
|
681 | + */ |
|
682 | 682 | public static function var2json($variable, int $options=0, int $depth=512) : string |
683 | 683 | { |
684 | 684 | return JSONConverter::var2json($variable, $options, $depth); |
@@ -726,12 +726,12 @@ discard block |
||
726 | 726 | ->toString(); |
727 | 727 | } |
728 | 728 | |
729 | - /** |
|
730 | - * Strips all known UTF byte order marks from the specified string. |
|
731 | - * |
|
732 | - * @param string $string |
|
733 | - * @return string |
|
734 | - */ |
|
729 | + /** |
|
730 | + * Strips all known UTF byte order marks from the specified string. |
|
731 | + * |
|
732 | + * @param string $string |
|
733 | + * @return string |
|
734 | + */ |
|
735 | 735 | public static function stripUTFBom(string $string) : string |
736 | 736 | { |
737 | 737 | $boms = FileHelper::createUnicodeHandling()->getUTFBOMs(); |
@@ -750,69 +750,69 @@ discard block |
||
750 | 750 | return $string; |
751 | 751 | } |
752 | 752 | |
753 | - /** |
|
754 | - * Converts a string to valid utf8, regardless |
|
755 | - * of the string's encoding(s). |
|
756 | - * |
|
757 | - * @param string $string |
|
758 | - * @return string |
|
759 | - */ |
|
753 | + /** |
|
754 | + * Converts a string to valid utf8, regardless |
|
755 | + * of the string's encoding(s). |
|
756 | + * |
|
757 | + * @param string $string |
|
758 | + * @return string |
|
759 | + */ |
|
760 | 760 | public static function string2utf8(string $string) : string |
761 | 761 | { |
762 | 762 | return ConvertHelper_String::toUtf8($string); |
763 | 763 | } |
764 | 764 | |
765 | - /** |
|
766 | - * Checks whether the specified string is an ASCII |
|
767 | - * string, without any special or UTF8 characters. |
|
768 | - * Note: empty strings and NULL are considered ASCII. |
|
769 | - * Any variable types other than strings are not. |
|
770 | - * |
|
771 | - * @param string|float|int|NULL $string |
|
772 | - * @return boolean |
|
773 | - */ |
|
765 | + /** |
|
766 | + * Checks whether the specified string is an ASCII |
|
767 | + * string, without any special or UTF8 characters. |
|
768 | + * Note: empty strings and NULL are considered ASCII. |
|
769 | + * Any variable types other than strings are not. |
|
770 | + * |
|
771 | + * @param string|float|int|NULL $string |
|
772 | + * @return boolean |
|
773 | + */ |
|
774 | 774 | public static function isStringASCII($string) : bool |
775 | 775 | { |
776 | 776 | return ConvertHelper_String::isASCII(strval($string)); |
777 | 777 | } |
778 | 778 | |
779 | - /** |
|
780 | - * Adds HTML syntax highlighting to an URL. |
|
781 | - * |
|
782 | - * NOTE: Includes the necessary CSS styles. When |
|
783 | - * highlighting several URLs in the same page, |
|
784 | - * prefer using the `parseURL` function instead. |
|
785 | - * |
|
786 | - * @param string $url |
|
787 | - * @return string |
|
788 | - * @deprecated Use the Highlighter class directly instead. |
|
789 | - * @see Highlighter |
|
790 | - */ |
|
779 | + /** |
|
780 | + * Adds HTML syntax highlighting to an URL. |
|
781 | + * |
|
782 | + * NOTE: Includes the necessary CSS styles. When |
|
783 | + * highlighting several URLs in the same page, |
|
784 | + * prefer using the `parseURL` function instead. |
|
785 | + * |
|
786 | + * @param string $url |
|
787 | + * @return string |
|
788 | + * @deprecated Use the Highlighter class directly instead. |
|
789 | + * @see Highlighter |
|
790 | + */ |
|
791 | 791 | public static function highlight_url(string $url) : string |
792 | 792 | { |
793 | 793 | return Highlighter::url($url); |
794 | 794 | } |
795 | 795 | |
796 | - /** |
|
797 | - * Calculates a percentage match of the source string with the target string. |
|
798 | - * |
|
799 | - * Options are: |
|
800 | - * |
|
801 | - * - maxLevenshtein, default: 10 |
|
802 | - * Any levenshtein results above this value are ignored. |
|
803 | - * |
|
804 | - * - precision, default: 1 |
|
805 | - * The precision of the percentage float value |
|
806 | - * |
|
807 | - * @param string $source |
|
808 | - * @param string $target |
|
809 | - * @param array<string,mixed> $options |
|
810 | - * @return float |
|
811 | - * |
|
812 | - * @see ConvertHelper_TextComparer |
|
813 | - * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE |
|
814 | - * @see ConvertHelper_TextComparer::OPTION_PRECISION |
|
815 | - */ |
|
796 | + /** |
|
797 | + * Calculates a percentage match of the source string with the target string. |
|
798 | + * |
|
799 | + * Options are: |
|
800 | + * |
|
801 | + * - maxLevenshtein, default: 10 |
|
802 | + * Any levenshtein results above this value are ignored. |
|
803 | + * |
|
804 | + * - precision, default: 1 |
|
805 | + * The precision of the percentage float value |
|
806 | + * |
|
807 | + * @param string $source |
|
808 | + * @param string $target |
|
809 | + * @param array<string,mixed> $options |
|
810 | + * @return float |
|
811 | + * |
|
812 | + * @see ConvertHelper_TextComparer |
|
813 | + * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE |
|
814 | + * @see ConvertHelper_TextComparer::OPTION_PRECISION |
|
815 | + */ |
|
816 | 816 | public static function matchString(string $source, string $target, array $options=array()) : float |
817 | 817 | { |
818 | 818 | return (new ConvertHelper_TextComparer()) |
@@ -820,109 +820,109 @@ discard block |
||
820 | 820 | ->match($source, $target); |
821 | 821 | } |
822 | 822 | |
823 | - /** |
|
824 | - * Converts a date interval to a human-readable string with |
|
825 | - * all necessary time components, e.g. "1 year, 2 months and 4 days". |
|
826 | - * |
|
827 | - * @param DateInterval $interval |
|
828 | - * @return string |
|
829 | - * @see ConvertHelper_IntervalConverter |
|
830 | - * |
|
831 | - * @throws ConvertHelper_Exception |
|
832 | - * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION |
|
833 | - */ |
|
823 | + /** |
|
824 | + * Converts a date interval to a human-readable string with |
|
825 | + * all necessary time components, e.g. "1 year, 2 months and 4 days". |
|
826 | + * |
|
827 | + * @param DateInterval $interval |
|
828 | + * @return string |
|
829 | + * @see ConvertHelper_IntervalConverter |
|
830 | + * |
|
831 | + * @throws ConvertHelper_Exception |
|
832 | + * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION |
|
833 | + */ |
|
834 | 834 | public static function interval2string(DateInterval $interval) : string |
835 | 835 | { |
836 | 836 | return (new ConvertHelper_IntervalConverter()) |
837 | 837 | ->toString($interval); |
838 | 838 | } |
839 | 839 | |
840 | - /** |
|
841 | - * Converts an interval to its total amount of days. |
|
842 | - * @param DateInterval $interval |
|
843 | - * @return int |
|
844 | - */ |
|
840 | + /** |
|
841 | + * Converts an interval to its total amount of days. |
|
842 | + * @param DateInterval $interval |
|
843 | + * @return int |
|
844 | + */ |
|
845 | 845 | public static function interval2days(DateInterval $interval) : int |
846 | 846 | { |
847 | 847 | return ConvertHelper_DateInterval::toDays($interval); |
848 | 848 | } |
849 | 849 | |
850 | - /** |
|
851 | - * Converts an interval to its total amount of hours. |
|
852 | - * @param DateInterval $interval |
|
853 | - * @return int |
|
854 | - */ |
|
850 | + /** |
|
851 | + * Converts an interval to its total amount of hours. |
|
852 | + * @param DateInterval $interval |
|
853 | + * @return int |
|
854 | + */ |
|
855 | 855 | public static function interval2hours(DateInterval $interval) : int |
856 | 856 | { |
857 | 857 | return ConvertHelper_DateInterval::toHours($interval); |
858 | 858 | } |
859 | 859 | |
860 | - /** |
|
861 | - * Converts an interval to its total amount of minutes. |
|
862 | - * @param DateInterval $interval |
|
863 | - * @return int |
|
864 | - */ |
|
860 | + /** |
|
861 | + * Converts an interval to its total amount of minutes. |
|
862 | + * @param DateInterval $interval |
|
863 | + * @return int |
|
864 | + */ |
|
865 | 865 | public static function interval2minutes(DateInterval $interval) : int |
866 | 866 | { |
867 | 867 | return ConvertHelper_DateInterval::toMinutes($interval); |
868 | 868 | } |
869 | 869 | |
870 | - /** |
|
871 | - * Converts an interval to its total amount of seconds. |
|
872 | - * @param DateInterval $interval |
|
873 | - * @return int |
|
874 | - */ |
|
870 | + /** |
|
871 | + * Converts an interval to its total amount of seconds. |
|
872 | + * @param DateInterval $interval |
|
873 | + * @return int |
|
874 | + */ |
|
875 | 875 | public static function interval2seconds(DateInterval $interval) : int |
876 | 876 | { |
877 | 877 | return ConvertHelper_DateInterval::toSeconds($interval); |
878 | 878 | } |
879 | 879 | |
880 | - /** |
|
881 | - * Calculates the total amount of days / hours / minutes or seconds |
|
882 | - * of a date interval object (depending on the specified units), and |
|
883 | - * returns the total amount. |
|
884 | - * |
|
885 | - * @param DateInterval $interval |
|
886 | - * @param string $unit What total value to calculate. |
|
887 | - * @return integer |
|
888 | - * |
|
889 | - * @see ConvertHelper::INTERVAL_SECONDS |
|
890 | - * @see ConvertHelper::INTERVAL_MINUTES |
|
891 | - * @see ConvertHelper::INTERVAL_HOURS |
|
892 | - * @see ConvertHelper::INTERVAL_DAYS |
|
893 | - */ |
|
880 | + /** |
|
881 | + * Calculates the total amount of days / hours / minutes or seconds |
|
882 | + * of a date interval object (depending on the specified units), and |
|
883 | + * returns the total amount. |
|
884 | + * |
|
885 | + * @param DateInterval $interval |
|
886 | + * @param string $unit What total value to calculate. |
|
887 | + * @return integer |
|
888 | + * |
|
889 | + * @see ConvertHelper::INTERVAL_SECONDS |
|
890 | + * @see ConvertHelper::INTERVAL_MINUTES |
|
891 | + * @see ConvertHelper::INTERVAL_HOURS |
|
892 | + * @see ConvertHelper::INTERVAL_DAYS |
|
893 | + */ |
|
894 | 894 | public static function interval2total(DateInterval $interval, string $unit=self::INTERVAL_SECONDS) : int |
895 | 895 | { |
896 | 896 | return ConvertHelper_DateInterval::toTotal($interval, $unit); |
897 | 897 | } |
898 | 898 | |
899 | - /** |
|
900 | - * Converts a date to the corresponding day name. |
|
901 | - * |
|
902 | - * @param DateTime $date |
|
903 | - * @param bool $short |
|
904 | - * @return string|NULL |
|
905 | - */ |
|
899 | + /** |
|
900 | + * Converts a date to the corresponding day name. |
|
901 | + * |
|
902 | + * @param DateTime $date |
|
903 | + * @param bool $short |
|
904 | + * @return string|NULL |
|
905 | + */ |
|
906 | 906 | public static function date2dayName(DateTime $date, bool $short=false) : ?string |
907 | 907 | { |
908 | 908 | return ConvertHelper_Date::toDayName($date, $short); |
909 | 909 | } |
910 | 910 | |
911 | - /** |
|
912 | - * Retrieves a list of english day names. |
|
913 | - * @return string[] |
|
914 | - */ |
|
911 | + /** |
|
912 | + * Retrieves a list of english day names. |
|
913 | + * @return string[] |
|
914 | + */ |
|
915 | 915 | public static function getDayNamesInvariant() : array |
916 | 916 | { |
917 | 917 | return ConvertHelper_Date::getDayNamesInvariant(); |
918 | 918 | } |
919 | 919 | |
920 | - /** |
|
921 | - * Retrieves the day names list for the current locale. |
|
922 | - * |
|
923 | - * @param bool $short |
|
924 | - * @return string[] |
|
925 | - */ |
|
920 | + /** |
|
921 | + * Retrieves the day names list for the current locale. |
|
922 | + * |
|
923 | + * @param bool $short |
|
924 | + * @return string[] |
|
925 | + */ |
|
926 | 926 | public static function getDayNames(bool $short=false) : array |
927 | 927 | { |
928 | 928 | return ConvertHelper_Date::getDayNames($short); |
@@ -941,16 +941,16 @@ discard block |
||
941 | 941 | return ConvertHelper_Array::implodeWithAnd($list, $sep, $conjunction); |
942 | 942 | } |
943 | 943 | |
944 | - /** |
|
945 | - * Splits a string into an array of all characters it is composed of. |
|
946 | - * Unicode character safe. |
|
947 | - * |
|
948 | - * NOTE: Spaces and newlines (both \r and \n) are also considered single |
|
949 | - * characters. |
|
950 | - * |
|
951 | - * @param string $string |
|
952 | - * @return string[] |
|
953 | - */ |
|
944 | + /** |
|
945 | + * Splits a string into an array of all characters it is composed of. |
|
946 | + * Unicode character safe. |
|
947 | + * |
|
948 | + * NOTE: Spaces and newlines (both \r and \n) are also considered single |
|
949 | + * characters. |
|
950 | + * |
|
951 | + * @param string $string |
|
952 | + * @return string[] |
|
953 | + */ |
|
954 | 954 | public static function string2array(string $string) : array |
955 | 955 | { |
956 | 956 | return ConvertHelper_String::toArray($string); |
@@ -961,53 +961,53 @@ discard block |
||
961 | 961 | return new WordSplitter($string); |
962 | 962 | } |
963 | 963 | |
964 | - /** |
|
965 | - * Checks whether the specified string contains HTML code. |
|
966 | - * |
|
967 | - * @param string $string |
|
968 | - * @return boolean |
|
969 | - */ |
|
964 | + /** |
|
965 | + * Checks whether the specified string contains HTML code. |
|
966 | + * |
|
967 | + * @param string $string |
|
968 | + * @return boolean |
|
969 | + */ |
|
970 | 970 | public static function isStringHTML(string $string) : bool |
971 | 971 | { |
972 | 972 | return ConvertHelper_String::isHTML($string); |
973 | 973 | } |
974 | 974 | |
975 | - /** |
|
976 | - * UTF8-safe wordwrap method: works like the regular wordwrap |
|
977 | - * PHP function but compatible with UTF8. Otherwise the lengths |
|
978 | - * are not calculated correctly. |
|
979 | - * |
|
980 | - * @param string $str |
|
981 | - * @param int $width |
|
982 | - * @param string $break |
|
983 | - * @param bool $cut |
|
984 | - * @return string |
|
985 | - */ |
|
975 | + /** |
|
976 | + * UTF8-safe wordwrap method: works like the regular wordwrap |
|
977 | + * PHP function but compatible with UTF8. Otherwise the lengths |
|
978 | + * are not calculated correctly. |
|
979 | + * |
|
980 | + * @param string $str |
|
981 | + * @param int $width |
|
982 | + * @param string $break |
|
983 | + * @param bool $cut |
|
984 | + * @return string |
|
985 | + */ |
|
986 | 986 | public static function wordwrap(string $str, int $width = 75, string $break = "\n", bool $cut = false) : string |
987 | 987 | { |
988 | 988 | return ConvertHelper_String::wordwrap($str, $width, $break, $cut); |
989 | 989 | } |
990 | 990 | |
991 | - /** |
|
992 | - * Calculates the byte length of a string, taking into |
|
993 | - * account any unicode characters. |
|
994 | - * |
|
995 | - * @param string $string |
|
996 | - * @return int |
|
997 | - */ |
|
991 | + /** |
|
992 | + * Calculates the byte length of a string, taking into |
|
993 | + * account any unicode characters. |
|
994 | + * |
|
995 | + * @param string $string |
|
996 | + * @return int |
|
997 | + */ |
|
998 | 998 | public static function string2bytes(string $string): int |
999 | 999 | { |
1000 | 1000 | return ConvertHelper_String::toBytes($string); |
1001 | 1001 | } |
1002 | 1002 | |
1003 | - /** |
|
1004 | - * Creates a short, 8-character long hash for the specified string. |
|
1005 | - * |
|
1006 | - * WARNING: Not cryptographically safe. |
|
1007 | - * |
|
1008 | - * @param string $string |
|
1009 | - * @return string |
|
1010 | - */ |
|
1003 | + /** |
|
1004 | + * Creates a short, 8-character long hash for the specified string. |
|
1005 | + * |
|
1006 | + * WARNING: Not cryptographically safe. |
|
1007 | + * |
|
1008 | + * @param string $string |
|
1009 | + * @return string |
|
1010 | + */ |
|
1011 | 1011 | public static function string2shortHash(string $string) : string |
1012 | 1012 | { |
1013 | 1013 | return ConvertHelper_String::toShortHash($string); |
@@ -1053,88 +1053,88 @@ discard block |
||
1053 | 1053 | return ConvertHelper_ThrowableInfo::fromThrowable($e); |
1054 | 1054 | } |
1055 | 1055 | |
1056 | - /** |
|
1057 | - * Parses the specified query string like the native |
|
1058 | - * function <code>parse_str</code>, without the key |
|
1059 | - * naming limitations. |
|
1060 | - * |
|
1061 | - * Using parse_str, dots or spaces in key names are |
|
1062 | - * replaced by underscores. This method keeps all names |
|
1063 | - * intact. |
|
1064 | - * |
|
1065 | - * It still uses the parse_str implementation as it |
|
1066 | - * is tested and tried, but fixes the parameter names |
|
1067 | - * after parsing, as needed. |
|
1068 | - * |
|
1069 | - * @param string $queryString |
|
1070 | - * @return array<string,string> |
|
1071 | - * @see ConvertHelper_QueryParser |
|
1072 | - */ |
|
1056 | + /** |
|
1057 | + * Parses the specified query string like the native |
|
1058 | + * function <code>parse_str</code>, without the key |
|
1059 | + * naming limitations. |
|
1060 | + * |
|
1061 | + * Using parse_str, dots or spaces in key names are |
|
1062 | + * replaced by underscores. This method keeps all names |
|
1063 | + * intact. |
|
1064 | + * |
|
1065 | + * It still uses the parse_str implementation as it |
|
1066 | + * is tested and tried, but fixes the parameter names |
|
1067 | + * after parsing, as needed. |
|
1068 | + * |
|
1069 | + * @param string $queryString |
|
1070 | + * @return array<string,string> |
|
1071 | + * @see ConvertHelper_QueryParser |
|
1072 | + */ |
|
1073 | 1073 | public static function parseQueryString(string $queryString) : array |
1074 | 1074 | { |
1075 | 1075 | $parser = new ConvertHelper_QueryParser(); |
1076 | 1076 | return $parser->parse($queryString); |
1077 | 1077 | } |
1078 | 1078 | |
1079 | - /** |
|
1080 | - * Searches for needle in the specified string, and returns a list |
|
1081 | - * of all occurrences, including the matched string. The matched |
|
1082 | - * string is useful when doing a case-insensitive search, as it |
|
1083 | - * shows the exact matched case of needle. |
|
1084 | - * |
|
1085 | - * @param string $needle |
|
1086 | - * @param string $haystack |
|
1087 | - * @param bool $caseInsensitive |
|
1088 | - * @return ConvertHelper_StringMatch[] |
|
1089 | - */ |
|
1079 | + /** |
|
1080 | + * Searches for needle in the specified string, and returns a list |
|
1081 | + * of all occurrences, including the matched string. The matched |
|
1082 | + * string is useful when doing a case-insensitive search, as it |
|
1083 | + * shows the exact matched case of needle. |
|
1084 | + * |
|
1085 | + * @param string $needle |
|
1086 | + * @param string $haystack |
|
1087 | + * @param bool $caseInsensitive |
|
1088 | + * @return ConvertHelper_StringMatch[] |
|
1089 | + */ |
|
1090 | 1090 | public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array |
1091 | 1091 | { |
1092 | 1092 | return ConvertHelper_String::findString($needle, $haystack, $caseInsensitive); |
1093 | 1093 | } |
1094 | 1094 | |
1095 | - /** |
|
1096 | - * Like explode, but trims all entries, and removes |
|
1097 | - * empty entries from the resulting array. |
|
1098 | - * |
|
1099 | - * @param string $delimiter |
|
1100 | - * @param string $string |
|
1101 | - * @return string[] |
|
1102 | - */ |
|
1095 | + /** |
|
1096 | + * Like explode, but trims all entries, and removes |
|
1097 | + * empty entries from the resulting array. |
|
1098 | + * |
|
1099 | + * @param string $delimiter |
|
1100 | + * @param string $string |
|
1101 | + * @return string[] |
|
1102 | + */ |
|
1103 | 1103 | public static function explodeTrim(string $delimiter, string $string) : array |
1104 | 1104 | { |
1105 | 1105 | return ConvertHelper_String::explodeTrim($delimiter, $string); |
1106 | 1106 | } |
1107 | 1107 | |
1108 | - /** |
|
1109 | - * Detects the most used end-of-line character in the subject string. |
|
1110 | - * |
|
1111 | - * @param string $subjectString The string to check. |
|
1112 | - * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected. |
|
1113 | - */ |
|
1108 | + /** |
|
1109 | + * Detects the most used end-of-line character in the subject string. |
|
1110 | + * |
|
1111 | + * @param string $subjectString The string to check. |
|
1112 | + * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected. |
|
1113 | + */ |
|
1114 | 1114 | public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL |
1115 | 1115 | { |
1116 | 1116 | return ConvertHelper_EOL::detect($subjectString); |
1117 | 1117 | } |
1118 | 1118 | |
1119 | - /** |
|
1120 | - * Removes the specified keys from the target array, |
|
1121 | - * if they exist. |
|
1122 | - * |
|
1123 | - * @param array<string|int,mixed> $array |
|
1124 | - * @param string[] $keys |
|
1125 | - */ |
|
1119 | + /** |
|
1120 | + * Removes the specified keys from the target array, |
|
1121 | + * if they exist. |
|
1122 | + * |
|
1123 | + * @param array<string|int,mixed> $array |
|
1124 | + * @param string[] $keys |
|
1125 | + */ |
|
1126 | 1126 | public static function arrayRemoveKeys(array &$array, array $keys) : void |
1127 | 1127 | { |
1128 | 1128 | ConvertHelper_Array::removeKeys($array, $keys); |
1129 | 1129 | } |
1130 | 1130 | |
1131 | - /** |
|
1132 | - * Checks if the specified variable is an integer or a string containing an integer. |
|
1133 | - * Accepts both positive and negative integers. |
|
1134 | - * |
|
1135 | - * @param mixed $value |
|
1136 | - * @return bool |
|
1137 | - */ |
|
1131 | + /** |
|
1132 | + * Checks if the specified variable is an integer or a string containing an integer. |
|
1133 | + * Accepts both positive and negative integers. |
|
1134 | + * |
|
1135 | + * @param mixed $value |
|
1136 | + * @return bool |
|
1137 | + */ |
|
1138 | 1138 | public static function isInteger($value) : bool |
1139 | 1139 | { |
1140 | 1140 | if(is_int($value)) { |
@@ -1154,52 +1154,52 @@ discard block |
||
1154 | 1154 | return false; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | - /** |
|
1158 | - * Converts an amount of seconds to a DateInterval object. |
|
1159 | - * |
|
1160 | - * @param int $seconds |
|
1161 | - * @return DateInterval |
|
1162 | - * @throws ConvertHelper_Exception If the date interval cannot be created. |
|
1163 | - * |
|
1164 | - * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF |
|
1165 | - */ |
|
1157 | + /** |
|
1158 | + * Converts an amount of seconds to a DateInterval object. |
|
1159 | + * |
|
1160 | + * @param int $seconds |
|
1161 | + * @return DateInterval |
|
1162 | + * @throws ConvertHelper_Exception If the date interval cannot be created. |
|
1163 | + * |
|
1164 | + * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF |
|
1165 | + */ |
|
1166 | 1166 | public static function seconds2interval(int $seconds) : DateInterval |
1167 | 1167 | { |
1168 | 1168 | return ConvertHelper_DateInterval::fromSeconds($seconds)->getInterval(); |
1169 | 1169 | } |
1170 | 1170 | |
1171 | - /** |
|
1172 | - * Converts a size string like "50 MB" to the corresponding byte size. |
|
1173 | - * It is case-insensitive, ignores spaces, and supports both traditional |
|
1174 | - * "MB" and "MiB" notations. |
|
1175 | - * |
|
1176 | - * @param string $size |
|
1177 | - * @return int |
|
1178 | - */ |
|
1171 | + /** |
|
1172 | + * Converts a size string like "50 MB" to the corresponding byte size. |
|
1173 | + * It is case-insensitive, ignores spaces, and supports both traditional |
|
1174 | + * "MB" and "MiB" notations. |
|
1175 | + * |
|
1176 | + * @param string $size |
|
1177 | + * @return int |
|
1178 | + */ |
|
1179 | 1179 | public static function size2bytes(string $size) : int |
1180 | 1180 | { |
1181 | 1181 | return self::parseSize($size)->toBytes(); |
1182 | 1182 | } |
1183 | 1183 | |
1184 | - /** |
|
1185 | - * Parses a size string like "50 MB" and returns a size notation instance |
|
1186 | - * that has utility methods to access information on it, and convert it. |
|
1187 | - * |
|
1188 | - * @param string $size |
|
1189 | - * @return ConvertHelper_SizeNotation |
|
1190 | - */ |
|
1184 | + /** |
|
1185 | + * Parses a size string like "50 MB" and returns a size notation instance |
|
1186 | + * that has utility methods to access information on it, and convert it. |
|
1187 | + * |
|
1188 | + * @param string $size |
|
1189 | + * @return ConvertHelper_SizeNotation |
|
1190 | + */ |
|
1191 | 1191 | public static function parseSize(string $size) : ConvertHelper_SizeNotation |
1192 | 1192 | { |
1193 | 1193 | return new ConvertHelper_SizeNotation($size); |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - /** |
|
1197 | - * Creates a URL finder instance, which can be used to find |
|
1198 | - * URLs in a string - be it plain text, or HTML. |
|
1199 | - * |
|
1200 | - * @param string $subject |
|
1201 | - * @return ConvertHelper_URLFinder |
|
1202 | - */ |
|
1196 | + /** |
|
1197 | + * Creates a URL finder instance, which can be used to find |
|
1198 | + * URLs in a string - be it plain text, or HTML. |
|
1199 | + * |
|
1200 | + * @param string $subject |
|
1201 | + * @return ConvertHelper_URLFinder |
|
1202 | + */ |
|
1203 | 1203 | public static function createURLFinder(string $subject) : ConvertHelper_URLFinder |
1204 | 1204 | { |
1205 | 1205 | return new ConvertHelper_URLFinder($subject); |