@@ -155,13 +155,13 @@ |
||
155 | 155 | ); |
156 | 156 | } |
157 | 157 | |
158 | - /** |
|
159 | - * Fetches all parameters in the URL, regardless of |
|
160 | - * whether parameter exclusion is enabled, so they |
|
161 | - * can be highlighted is need be. |
|
162 | - * |
|
163 | - * @return array<string,string> |
|
164 | - */ |
|
158 | + /** |
|
159 | + * Fetches all parameters in the URL, regardless of |
|
160 | + * whether parameter exclusion is enabled, so they |
|
161 | + * can be highlighted is need be. |
|
162 | + * |
|
163 | + * @return array<string,string> |
|
164 | + */ |
|
165 | 165 | protected function resolveParams() : array |
166 | 166 | { |
167 | 167 | $previous = $this->info->isParamExclusionEnabled(); |
@@ -44,42 +44,42 @@ discard block |
||
44 | 44 | public const TYPE_URL = 'url'; |
45 | 45 | public const TYPE_NONE = 'none'; |
46 | 46 | |
47 | - /** |
|
48 | - * The original URL that was passed to the constructor. |
|
49 | - * @var string |
|
50 | - */ |
|
47 | + /** |
|
48 | + * The original URL that was passed to the constructor. |
|
49 | + * @var string |
|
50 | + */ |
|
51 | 51 | protected string $rawURL; |
52 | 52 | |
53 | - /** |
|
54 | - * @var array<string,mixed> |
|
55 | - */ |
|
53 | + /** |
|
54 | + * @var array<string,mixed> |
|
55 | + */ |
|
56 | 56 | protected array $info; |
57 | 57 | |
58 | - /** |
|
59 | - * @var string[] |
|
60 | - */ |
|
58 | + /** |
|
59 | + * @var string[] |
|
60 | + */ |
|
61 | 61 | protected array $excludedParams = array(); |
62 | 62 | |
63 | - /** |
|
64 | - * @var bool |
|
65 | - * @see URLInfo::setParamExclusion() |
|
66 | - */ |
|
63 | + /** |
|
64 | + * @var bool |
|
65 | + * @see URLInfo::setParamExclusion() |
|
66 | + */ |
|
67 | 67 | protected bool $paramExclusion = false; |
68 | 68 | |
69 | - /** |
|
70 | - * @var array<string,string>|NULL |
|
71 | - * @see URLInfo::getTypeLabel() |
|
72 | - */ |
|
69 | + /** |
|
70 | + * @var array<string,string>|NULL |
|
71 | + * @see URLInfo::getTypeLabel() |
|
72 | + */ |
|
73 | 73 | protected static ?array $typeLabels = null; |
74 | 74 | |
75 | - /** |
|
76 | - * @var bool |
|
77 | - */ |
|
75 | + /** |
|
76 | + * @var bool |
|
77 | + */ |
|
78 | 78 | protected bool $highlightExcluded = false; |
79 | 79 | |
80 | - /** |
|
81 | - * @var string[] |
|
82 | - */ |
|
80 | + /** |
|
81 | + * @var string[] |
|
82 | + */ |
|
83 | 83 | protected array $infoKeys = array( |
84 | 84 | 'scheme', |
85 | 85 | 'host', |
@@ -91,24 +91,24 @@ discard block |
||
91 | 91 | 'fragment' |
92 | 92 | ); |
93 | 93 | |
94 | - /** |
|
95 | - * @var string |
|
96 | - */ |
|
94 | + /** |
|
95 | + * @var string |
|
96 | + */ |
|
97 | 97 | protected string $url; |
98 | 98 | |
99 | - /** |
|
100 | - * @var URIParser |
|
101 | - */ |
|
99 | + /** |
|
100 | + * @var URIParser |
|
101 | + */ |
|
102 | 102 | protected URIParser $parser; |
103 | 103 | |
104 | - /** |
|
105 | - * @var URINormalizer|NULL |
|
106 | - */ |
|
104 | + /** |
|
105 | + * @var URINormalizer|NULL |
|
106 | + */ |
|
107 | 107 | protected ?URINormalizer $normalizer = null; |
108 | 108 | |
109 | - /** |
|
110 | - * @var bool |
|
111 | - */ |
|
109 | + /** |
|
110 | + * @var bool |
|
111 | + */ |
|
112 | 112 | protected bool $encodeUTFChars = false; |
113 | 113 | |
114 | 114 | public function __construct(string $url) |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | $this->info = $this->parser->getInfo(); |
126 | 126 | } |
127 | 127 | |
128 | - /** |
|
129 | - * Whether to URL encode any non-encoded UTF8 characters in the URL. |
|
130 | - * Default is to leave them as-is for better readability, since |
|
131 | - * browsers handle this well. |
|
132 | - * |
|
133 | - * @param bool $enabled |
|
134 | - * @return URLInfo |
|
135 | - */ |
|
128 | + /** |
|
129 | + * Whether to URL encode any non-encoded UTF8 characters in the URL. |
|
130 | + * Default is to leave them as-is for better readability, since |
|
131 | + * browsers handle this well. |
|
132 | + * |
|
133 | + * @param bool $enabled |
|
134 | + * @return URLInfo |
|
135 | + */ |
|
136 | 136 | public function setUTFEncoding(bool $enabled=true) : URLInfo |
137 | 137 | { |
138 | 138 | if($this->encodeUTFChars !== $enabled) |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | return $this->encodeUTFChars; |
150 | 150 | } |
151 | 151 | |
152 | - /** |
|
153 | - * Filters a URL: removes control characters and the |
|
154 | - * like to have a clean URL to work with. |
|
155 | - * |
|
156 | - * @param string $url |
|
157 | - * @return string |
|
158 | - */ |
|
152 | + /** |
|
153 | + * Filters a URL: removes control characters and the |
|
154 | + * like to have a clean URL to work with. |
|
155 | + * |
|
156 | + * @param string $url |
|
157 | + * @return string |
|
158 | + */ |
|
159 | 159 | public static function filterURL(string $url) : string |
160 | 160 | { |
161 | 161 | return URIFilter::filter($url); |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | return $this->info['type'] === self::TYPE_PHONE; |
186 | 186 | } |
187 | 187 | |
188 | - /** |
|
189 | - * Whether the URL is a regular URL, not one of the |
|
190 | - * other types like a phone number or email address. |
|
191 | - * |
|
192 | - * @return bool |
|
193 | - */ |
|
188 | + /** |
|
189 | + * Whether the URL is a regular URL, not one of the |
|
190 | + * other types like a phone number or email address. |
|
191 | + * |
|
192 | + * @return bool |
|
193 | + */ |
|
194 | 194 | public function isURL() : bool |
195 | 195 | { |
196 | 196 | $host = $this->getHost(); |
@@ -202,20 +202,20 @@ discard block |
||
202 | 202 | return $this->parser->isValid(); |
203 | 203 | } |
204 | 204 | |
205 | - /** |
|
206 | - * Retrieves the host name, or an empty string if none is present. |
|
207 | - * |
|
208 | - * @return string |
|
209 | - */ |
|
205 | + /** |
|
206 | + * Retrieves the host name, or an empty string if none is present. |
|
207 | + * |
|
208 | + * @return string |
|
209 | + */ |
|
210 | 210 | public function getHost() : string |
211 | 211 | { |
212 | 212 | return $this->getInfoKey('host'); |
213 | 213 | } |
214 | 214 | |
215 | - /** |
|
216 | - * Retrieves the path, or an empty string if none is present. |
|
217 | - * @return string |
|
218 | - */ |
|
215 | + /** |
|
216 | + * Retrieves the path, or an empty string if none is present. |
|
217 | + * @return string |
|
218 | + */ |
|
219 | 219 | public function getPath() : string |
220 | 220 | { |
221 | 221 | return $this->getInfoKey('path'); |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | return $this->getInfoKey('scheme'); |
232 | 232 | } |
233 | 233 | |
234 | - /** |
|
235 | - * Retrieves the port specified in the URL, or -1 if none is present. |
|
236 | - * @return int |
|
237 | - */ |
|
234 | + /** |
|
235 | + * Retrieves the port specified in the URL, or -1 if none is present. |
|
236 | + * @return int |
|
237 | + */ |
|
238 | 238 | public function getPort() : int |
239 | 239 | { |
240 | 240 | $port = $this->getInfoKey('port'); |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | return -1; |
247 | 247 | } |
248 | 248 | |
249 | - /** |
|
250 | - * Retrieves the raw query string, or an empty string if none is present. |
|
251 | - * |
|
252 | - * @return string |
|
253 | - * |
|
254 | - * @see URLInfo::getParams() |
|
255 | - */ |
|
249 | + /** |
|
250 | + * Retrieves the raw query string, or an empty string if none is present. |
|
251 | + * |
|
252 | + * @return string |
|
253 | + * |
|
254 | + * @see URLInfo::getParams() |
|
255 | + */ |
|
256 | 256 | public function getQuery() : string |
257 | 257 | { |
258 | 258 | return $this->getInfoKey('query'); |
@@ -268,20 +268,20 @@ discard block |
||
268 | 268 | return $this->getInfoKey('pass'); |
269 | 269 | } |
270 | 270 | |
271 | - /** |
|
272 | - * Whether the URL contains a port number. |
|
273 | - * @return bool |
|
274 | - */ |
|
271 | + /** |
|
272 | + * Whether the URL contains a port number. |
|
273 | + * @return bool |
|
274 | + */ |
|
275 | 275 | public function hasPort() : bool |
276 | 276 | { |
277 | 277 | return $this->getPort() !== -1; |
278 | 278 | } |
279 | 279 | |
280 | - /** |
|
281 | - * Alias for the hasParams() method. |
|
282 | - * @return bool |
|
283 | - * @see URLInfo::hasParams() |
|
284 | - */ |
|
280 | + /** |
|
281 | + * Alias for the hasParams() method. |
|
282 | + * @return bool |
|
283 | + * @see URLInfo::hasParams() |
|
284 | + */ |
|
285 | 285 | public function hasQuery() : bool |
286 | 286 | { |
287 | 287 | return $this->hasParams(); |
@@ -326,23 +326,23 @@ discard block |
||
326 | 326 | return ''; |
327 | 327 | } |
328 | 328 | |
329 | - /** |
|
330 | - * Retrieves a normalized URL: this ensures that all parameters |
|
331 | - * in the URL are always in the same order. |
|
332 | - * |
|
333 | - * @return string |
|
334 | - */ |
|
329 | + /** |
|
330 | + * Retrieves a normalized URL: this ensures that all parameters |
|
331 | + * in the URL are always in the same order. |
|
332 | + * |
|
333 | + * @return string |
|
334 | + */ |
|
335 | 335 | public function getNormalized() : string |
336 | 336 | { |
337 | 337 | return $this->normalize(); |
338 | 338 | } |
339 | 339 | |
340 | - /** |
|
341 | - * Like getNormalized(), but if a username and password are present |
|
342 | - * in the URL, returns the URL without them. |
|
343 | - * |
|
344 | - * @return string |
|
345 | - */ |
|
340 | + /** |
|
341 | + * Like getNormalized(), but if a username and password are present |
|
342 | + * in the URL, returns the URL without them. |
|
343 | + * |
|
344 | + * @return string |
|
345 | + */ |
|
346 | 346 | public function getNormalizedWithoutAuth() : string |
347 | 347 | { |
348 | 348 | return $this->normalize(false); |
@@ -363,25 +363,25 @@ discard block |
||
363 | 363 | return $this->normalizer->normalize(); |
364 | 364 | } |
365 | 365 | |
366 | - /** |
|
367 | - * Creates a hash of the URL, which can be used for comparisons. |
|
368 | - * Since any parameters in the URL's query are sorted alphabetically, |
|
369 | - * the same links with a different parameter order will have the |
|
370 | - * same hash. |
|
371 | - * |
|
372 | - * @return string |
|
373 | - */ |
|
366 | + /** |
|
367 | + * Creates a hash of the URL, which can be used for comparisons. |
|
368 | + * Since any parameters in the URL's query are sorted alphabetically, |
|
369 | + * the same links with a different parameter order will have the |
|
370 | + * same hash. |
|
371 | + * |
|
372 | + * @return string |
|
373 | + */ |
|
374 | 374 | public function getHash() : string |
375 | 375 | { |
376 | 376 | return ConvertHelper::string2shortHash($this->getNormalized()); |
377 | 377 | } |
378 | 378 | |
379 | - /** |
|
380 | - * Highlights the URL using HTML tags with specific highlighting |
|
381 | - * class names. |
|
382 | - * |
|
383 | - * @return string Will return an empty string if the URL is not valid. |
|
384 | - */ |
|
379 | + /** |
|
380 | + * Highlights the URL using HTML tags with specific highlighting |
|
381 | + * class names. |
|
382 | + * |
|
383 | + * @return string Will return an empty string if the URL is not valid. |
|
384 | + */ |
|
385 | 385 | public function getHighlighted() : string |
386 | 386 | { |
387 | 387 | if(!$this->isValid()) { |
@@ -413,15 +413,15 @@ discard block |
||
413 | 413 | return count($params); |
414 | 414 | } |
415 | 415 | |
416 | - /** |
|
417 | - * Retrieves all parameters specified in the url, |
|
418 | - * if any, as an associative array. |
|
419 | - * |
|
420 | - * NOTE: Ignores parameters that have been added |
|
421 | - * to the excluded parameters list. |
|
422 | - * |
|
423 | - * @return array<string,string> |
|
424 | - */ |
|
416 | + /** |
|
417 | + * Retrieves all parameters specified in the url, |
|
418 | + * if any, as an associative array. |
|
419 | + * |
|
420 | + * NOTE: Ignores parameters that have been added |
|
421 | + * to the excluded parameters list. |
|
422 | + * |
|
423 | + * @return array<string,string> |
|
424 | + */ |
|
425 | 425 | public function getParams() : array |
426 | 426 | { |
427 | 427 | if(!$this->paramExclusion || empty($this->excludedParams)) { |
@@ -439,37 +439,37 @@ discard block |
||
439 | 439 | return $keep; |
440 | 440 | } |
441 | 441 | |
442 | - /** |
|
443 | - * Retrieves the names of all parameters present in the URL, if any. |
|
444 | - * @return string[] |
|
445 | - */ |
|
442 | + /** |
|
443 | + * Retrieves the names of all parameters present in the URL, if any. |
|
444 | + * @return string[] |
|
445 | + */ |
|
446 | 446 | public function getParamNames() : array |
447 | 447 | { |
448 | 448 | $params = $this->getParams(); |
449 | 449 | return array_keys($params); |
450 | 450 | } |
451 | 451 | |
452 | - /** |
|
453 | - * Retrieves a specific parameter value from the URL. |
|
454 | - * |
|
455 | - * @param string $name |
|
456 | - * @return string The parameter value, or an empty string if it does not exist. |
|
457 | - */ |
|
452 | + /** |
|
453 | + * Retrieves a specific parameter value from the URL. |
|
454 | + * |
|
455 | + * @param string $name |
|
456 | + * @return string The parameter value, or an empty string if it does not exist. |
|
457 | + */ |
|
458 | 458 | public function getParam(string $name) : string |
459 | 459 | { |
460 | 460 | return $this->info['params'][$name] ?? ''; |
461 | 461 | } |
462 | 462 | |
463 | - /** |
|
464 | - * Excludes a URL parameter entirely if present: |
|
465 | - * the parser will act as if the parameter was not |
|
466 | - * even present in the source URL, effectively |
|
467 | - * stripping it. |
|
468 | - * |
|
469 | - * @param string $name |
|
470 | - * @param string $reason A human-readable explanation why this is excluded - used when highlighting links. |
|
471 | - * @return URLInfo |
|
472 | - */ |
|
463 | + /** |
|
464 | + * Excludes a URL parameter entirely if present: |
|
465 | + * the parser will act as if the parameter was not |
|
466 | + * even present in the source URL, effectively |
|
467 | + * stripping it. |
|
468 | + * |
|
469 | + * @param string $name |
|
470 | + * @param string $reason A human-readable explanation why this is excluded - used when highlighting links. |
|
471 | + * @return URLInfo |
|
472 | + */ |
|
473 | 473 | public function excludeParam(string $name, string $reason='') : URLInfo |
474 | 474 | { |
475 | 475 | if(!isset($this->excludedParams[$name])) |
@@ -522,14 +522,14 @@ discard block |
||
522 | 522 | return self::$typeLabels[$this->getType()]; |
523 | 523 | } |
524 | 524 | |
525 | - /** |
|
526 | - * Whether excluded parameters should be highlighted in |
|
527 | - * a different color in the URL when using the |
|
528 | - * {@link URLInfo::getHighlighted()} method. |
|
529 | - * |
|
530 | - * @param bool $highlight |
|
531 | - * @return URLInfo |
|
532 | - */ |
|
525 | + /** |
|
526 | + * Whether excluded parameters should be highlighted in |
|
527 | + * a different color in the URL when using the |
|
528 | + * {@link URLInfo::getHighlighted()} method. |
|
529 | + * |
|
530 | + * @param bool $highlight |
|
531 | + * @return URLInfo |
|
532 | + */ |
|
533 | 533 | public function setHighlightExcluded(bool $highlight=true) : URLInfo |
534 | 534 | { |
535 | 535 | $this->highlightExcluded = $highlight; |
@@ -585,24 +585,24 @@ discard block |
||
585 | 585 | return $this; |
586 | 586 | } |
587 | 587 | |
588 | - /** |
|
589 | - * Whether the parameter exclusion mode is enabled: |
|
590 | - * In this case, if any parameters have been added to the |
|
591 | - * exclusion list, all relevant methods will exclude these. |
|
592 | - * |
|
593 | - * @return bool |
|
594 | - */ |
|
588 | + /** |
|
589 | + * Whether the parameter exclusion mode is enabled: |
|
590 | + * In this case, if any parameters have been added to the |
|
591 | + * exclusion list, all relevant methods will exclude these. |
|
592 | + * |
|
593 | + * @return bool |
|
594 | + */ |
|
595 | 595 | public function isParamExclusionEnabled() : bool |
596 | 596 | { |
597 | 597 | return $this->paramExclusion; |
598 | 598 | } |
599 | 599 | |
600 | - /** |
|
601 | - * Checks whether the link contains any parameters that |
|
602 | - * are on the list of excluded parameters. |
|
603 | - * |
|
604 | - * @return bool |
|
605 | - */ |
|
600 | + /** |
|
601 | + * Checks whether the link contains any parameters that |
|
602 | + * are on the list of excluded parameters. |
|
603 | + * |
|
604 | + * @return bool |
|
605 | + */ |
|
606 | 606 | public function containsExcludedParams() : bool |
607 | 607 | { |
608 | 608 | if(empty($this->excludedParams)) { |
@@ -690,26 +690,26 @@ discard block |
||
690 | 690 | ->canConnect(); |
691 | 691 | } |
692 | 692 | |
693 | - /** |
|
694 | - * Creates the connection tester instance that is used |
|
695 | - * to check if a URL can be connected to, and which is |
|
696 | - * used in the {@see URLInfo::tryConnect()} method. It |
|
697 | - * allows more settings to be used. |
|
698 | - * |
|
699 | - * @return URIConnectionTester |
|
700 | - */ |
|
693 | + /** |
|
694 | + * Creates the connection tester instance that is used |
|
695 | + * to check if a URL can be connected to, and which is |
|
696 | + * used in the {@see URLInfo::tryConnect()} method. It |
|
697 | + * allows more settings to be used. |
|
698 | + * |
|
699 | + * @return URIConnectionTester |
|
700 | + */ |
|
701 | 701 | public function createConnectionTester() : URIConnectionTester |
702 | 702 | { |
703 | 703 | return new URIConnectionTester($this); |
704 | 704 | } |
705 | 705 | |
706 | - /** |
|
707 | - * Adds/overwrites a URL parameter. |
|
708 | - * |
|
709 | - * @param string $name |
|
710 | - * @param string $val |
|
711 | - * @return URLInfo |
|
712 | - */ |
|
706 | + /** |
|
707 | + * Adds/overwrites a URL parameter. |
|
708 | + * |
|
709 | + * @param string $name |
|
710 | + * @param string $val |
|
711 | + * @return URLInfo |
|
712 | + */ |
|
713 | 713 | public function setParam(string $name, string $val) : URLInfo |
714 | 714 | { |
715 | 715 | $this->info['params'][$name] = $val; |
@@ -717,13 +717,13 @@ discard block |
||
717 | 717 | return $this; |
718 | 718 | } |
719 | 719 | |
720 | - /** |
|
721 | - * Removes a URL parameter. Has no effect if the |
|
722 | - * parameter is not present to begin with. |
|
723 | - * |
|
724 | - * @param string $param |
|
725 | - * @return URLInfo |
|
726 | - */ |
|
720 | + /** |
|
721 | + * Removes a URL parameter. Has no effect if the |
|
722 | + * parameter is not present to begin with. |
|
723 | + * |
|
724 | + * @param string $param |
|
725 | + * @return URLInfo |
|
726 | + */ |
|
727 | 727 | public function removeParam(string $param) : URLInfo |
728 | 728 | { |
729 | 729 | if(isset($this->info['params'][$param])) |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | - /** |
|
66 | - * The end of line character used in the INI source string. |
|
67 | - * @return string |
|
68 | - */ |
|
65 | + /** |
|
66 | + * The end of line character used in the INI source string. |
|
67 | + * @return string |
|
68 | + */ |
|
69 | 69 | public function getEOLChar() : string |
70 | 70 | { |
71 | 71 | return $this->eol; |
@@ -99,35 +99,35 @@ discard block |
||
99 | 99 | ); |
100 | 100 | } |
101 | 101 | |
102 | - /** |
|
103 | - * Factory method: Creates a new ini helper instance from an ini string. |
|
104 | - * |
|
105 | - * @param string $iniContent |
|
106 | - * @return IniHelper |
|
107 | - */ |
|
102 | + /** |
|
103 | + * Factory method: Creates a new ini helper instance from an ini string. |
|
104 | + * |
|
105 | + * @param string $iniContent |
|
106 | + * @return IniHelper |
|
107 | + */ |
|
108 | 108 | public static function createFromString(string $iniContent) : IniHelper |
109 | 109 | { |
110 | 110 | return new IniHelper($iniContent); |
111 | 111 | } |
112 | 112 | |
113 | - /** |
|
114 | - * Factory method: Creates a new empty ini helper. |
|
115 | - * |
|
116 | - * @return IniHelper |
|
117 | - */ |
|
113 | + /** |
|
114 | + * Factory method: Creates a new empty ini helper. |
|
115 | + * |
|
116 | + * @return IniHelper |
|
117 | + */ |
|
118 | 118 | public static function createNew() : IniHelper |
119 | 119 | { |
120 | 120 | return self::createFromString(''); |
121 | 121 | } |
122 | 122 | |
123 | - /** |
|
124 | - * Adds a new data section, and returns the section instance. |
|
125 | - * If a section with the name already exists, returns that |
|
126 | - * section instead of creating a new one. |
|
127 | - * |
|
128 | - * @param string $name |
|
129 | - * @return IniHelper_Section |
|
130 | - */ |
|
123 | + /** |
|
124 | + * Adds a new data section, and returns the section instance. |
|
125 | + * If a section with the name already exists, returns that |
|
126 | + * section instead of creating a new one. |
|
127 | + * |
|
128 | + * @param string $name |
|
129 | + * @return IniHelper_Section |
|
130 | + */ |
|
131 | 131 | public function addSection(string $name) : IniHelper_Section |
132 | 132 | { |
133 | 133 | if(!isset($this->sections[$name])) { |
@@ -137,22 +137,22 @@ discard block |
||
137 | 137 | return $this->sections[$name]; |
138 | 138 | } |
139 | 139 | |
140 | - /** |
|
141 | - * Retrieves a section by its name, if it exists. |
|
142 | - * |
|
143 | - * @param string $name |
|
144 | - * @return IniHelper_Section|NULL |
|
145 | - */ |
|
140 | + /** |
|
141 | + * Retrieves a section by its name, if it exists. |
|
142 | + * |
|
143 | + * @param string $name |
|
144 | + * @return IniHelper_Section|NULL |
|
145 | + */ |
|
146 | 146 | public function getSection(string $name) : ?IniHelper_Section |
147 | 147 | { |
148 | 148 | return $this->sections[$name] ?? null; |
149 | 149 | } |
150 | 150 | |
151 | - /** |
|
152 | - * Gets the data from the INI file as an associative array. |
|
153 | - * |
|
154 | - * @return array<string,mixed> |
|
155 | - */ |
|
151 | + /** |
|
152 | + * Gets the data from the INI file as an associative array. |
|
153 | + * |
|
154 | + * @return array<string,mixed> |
|
155 | + */ |
|
156 | 156 | public function toArray() : array |
157 | 157 | { |
158 | 158 | $result = array(); |
@@ -172,17 +172,17 @@ discard block |
||
172 | 172 | return $result; |
173 | 173 | } |
174 | 174 | |
175 | - /** |
|
176 | - * Saves the INI content to the target file. |
|
177 | - * |
|
178 | - * @param string $filePath |
|
179 | - * @return IniHelper |
|
180 | - * @throws FileHelper_Exception |
|
181 | - * |
|
182 | - * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
183 | - * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
184 | - * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
185 | - */ |
|
175 | + /** |
|
176 | + * Saves the INI content to the target file. |
|
177 | + * |
|
178 | + * @param string $filePath |
|
179 | + * @return IniHelper |
|
180 | + * @throws FileHelper_Exception |
|
181 | + * |
|
182 | + * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
183 | + * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
184 | + * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
185 | + */ |
|
186 | 186 | public function saveToFile(string $filePath) : IniHelper |
187 | 187 | { |
188 | 188 | FileHelper::saveFile($filePath, $this->saveToString()); |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | return $this; |
191 | 191 | } |
192 | 192 | |
193 | - /** |
|
194 | - * Returns the INI content as string. |
|
195 | - * |
|
196 | - * @return string |
|
197 | - */ |
|
193 | + /** |
|
194 | + * Returns the INI content as string. |
|
195 | + * |
|
196 | + * @return string |
|
197 | + */ |
|
198 | 198 | public function saveToString() : string |
199 | 199 | { |
200 | 200 | $parts = array(); |
@@ -207,15 +207,15 @@ discard block |
||
207 | 207 | return implode($this->eol, $parts); |
208 | 208 | } |
209 | 209 | |
210 | - /** |
|
211 | - * Sets or adds the value of a setting in the INI content. |
|
212 | - * If the setting does not exist, it is added. Otherwise, |
|
213 | - * the existing value is overwritten. |
|
214 | - * |
|
215 | - * @param string $path A variable path, either <code>varname</code> or <code>section.varname</code>. |
|
216 | - * @param mixed $value |
|
217 | - * @return IniHelper |
|
218 | - */ |
|
210 | + /** |
|
211 | + * Sets or adds the value of a setting in the INI content. |
|
212 | + * If the setting does not exist, it is added. Otherwise, |
|
213 | + * the existing value is overwritten. |
|
214 | + * |
|
215 | + * @param string $path A variable path, either <code>varname</code> or <code>section.varname</code>. |
|
216 | + * @param mixed $value |
|
217 | + * @return IniHelper |
|
218 | + */ |
|
219 | 219 | public function setValue(string $path, $value) : IniHelper |
220 | 220 | { |
221 | 221 | $info = $this->parsePath($path); |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | return $this; |
240 | 240 | } |
241 | 241 | |
242 | - /** |
|
243 | - * Checks whether a section with the specified name exists. |
|
244 | - * |
|
245 | - * @param string $name |
|
246 | - * @return bool |
|
247 | - */ |
|
242 | + /** |
|
243 | + * Checks whether a section with the specified name exists. |
|
244 | + * |
|
245 | + * @param string $name |
|
246 | + * @return bool |
|
247 | + */ |
|
248 | 248 | public function sectionExists(string $name) : bool |
249 | 249 | { |
250 | 250 | foreach($this->sections as $section) { |
@@ -256,23 +256,23 @@ discard block |
||
256 | 256 | return false; |
257 | 257 | } |
258 | 258 | |
259 | - /** |
|
260 | - * Retrieves the default section, which is used to add |
|
261 | - * values in the root of the document. |
|
262 | - * |
|
263 | - * @return IniHelper_Section |
|
264 | - */ |
|
259 | + /** |
|
260 | + * Retrieves the default section, which is used to add |
|
261 | + * values in the root of the document. |
|
262 | + * |
|
263 | + * @return IniHelper_Section |
|
264 | + */ |
|
265 | 265 | public function getDefaultSection() : IniHelper_Section |
266 | 266 | { |
267 | 267 | return $this->addSection(self::SECTION_DEFAULT); |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
271 | - * Retrieves all variable lines for the specified path. |
|
272 | - * |
|
273 | - * @param string $path A variable path. Either <code>varname</code> or <code>section.varname</code>. |
|
274 | - * @return INILine[] |
|
275 | - */ |
|
270 | + /** |
|
271 | + * Retrieves all variable lines for the specified path. |
|
272 | + * |
|
273 | + * @param string $path A variable path. Either <code>varname</code> or <code>section.varname</code>. |
|
274 | + * @return INILine[] |
|
275 | + */ |
|
276 | 276 | public function getLinesByVariable(string $path) : array |
277 | 277 | { |
278 | 278 | $info = $this->parsePath($path); |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | protected IniHelper $ini; |
27 | 27 | protected string $name; |
28 | 28 | |
29 | - /** |
|
30 | - * @var INILine[] |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var INILine[] |
|
31 | + */ |
|
32 | 32 | protected array $lines = array(); |
33 | 33 | |
34 | 34 | public function __construct(IniHelper $ini, string $name) |
@@ -37,33 +37,33 @@ discard block |
||
37 | 37 | $this->name = $name; |
38 | 38 | } |
39 | 39 | |
40 | - /** |
|
41 | - * The section's name. |
|
42 | - * @return string |
|
43 | - */ |
|
40 | + /** |
|
41 | + * The section's name. |
|
42 | + * @return string |
|
43 | + */ |
|
44 | 44 | public function getName() : string |
45 | 45 | { |
46 | 46 | return $this->name; |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * Whether this is the default section: this |
|
51 | - * is used internally to store all variables that |
|
52 | - * are not in any specific section. |
|
53 | - * |
|
54 | - * @return bool |
|
55 | - */ |
|
49 | + /** |
|
50 | + * Whether this is the default section: this |
|
51 | + * is used internally to store all variables that |
|
52 | + * are not in any specific section. |
|
53 | + * |
|
54 | + * @return bool |
|
55 | + */ |
|
56 | 56 | public function isDefault() : bool |
57 | 57 | { |
58 | 58 | return $this->name === IniHelper::SECTION_DEFAULT; |
59 | 59 | } |
60 | 60 | |
61 | - /** |
|
62 | - * Adds a line instance to the section. |
|
63 | - * |
|
64 | - * @param INILine $line |
|
65 | - * @return IniHelper_Section |
|
66 | - */ |
|
61 | + /** |
|
62 | + * Adds a line instance to the section. |
|
63 | + * |
|
64 | + * @param INILine $line |
|
65 | + * @return IniHelper_Section |
|
66 | + */ |
|
67 | 67 | public function addLine(INILine $line) : IniHelper_Section |
68 | 68 | { |
69 | 69 | $this->lines[] = $line; |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
74 | - /** |
|
75 | - * Converts the values contained in the section into |
|
76 | - * an associative array. |
|
77 | - * |
|
78 | - * @return array<string,array<int,string>> |
|
79 | - */ |
|
74 | + /** |
|
75 | + * Converts the values contained in the section into |
|
76 | + * an associative array. |
|
77 | + * |
|
78 | + * @return array<string,array<int,string>> |
|
79 | + */ |
|
80 | 80 | public function toArray() : array |
81 | 81 | { |
82 | 82 | $result = array(); |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | return implode($this->ini->getEOLChar(), $lines); |
137 | 137 | } |
138 | 138 | |
139 | - /** |
|
140 | - * Deletes a line from the section. |
|
141 | - * |
|
142 | - * @param INILine $toDelete |
|
143 | - * @return IniHelper_Section |
|
144 | - */ |
|
139 | + /** |
|
140 | + * Deletes a line from the section. |
|
141 | + * |
|
142 | + * @param INILine $toDelete |
|
143 | + * @return IniHelper_Section |
|
144 | + */ |
|
145 | 145 | public function deleteLine(INILine $toDelete) : IniHelper_Section |
146 | 146 | { |
147 | 147 | $keep = array(); |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | return $this; |
227 | 227 | } |
228 | 228 | |
229 | - /** |
|
230 | - * Adds a variable value to the section. Unlike setValue(), this |
|
231 | - * will not overwrite any existing value. If the name is an existing |
|
232 | - * variable name, it will be converted to duplicate keys. |
|
233 | - * |
|
234 | - * @param string $name |
|
235 | - * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added. |
|
236 | - * @return IniHelper_Section |
|
237 | - */ |
|
229 | + /** |
|
230 | + * Adds a variable value to the section. Unlike setValue(), this |
|
231 | + * will not overwrite any existing value. If the name is an existing |
|
232 | + * variable name, it will be converted to duplicate keys. |
|
233 | + * |
|
234 | + * @param string $name |
|
235 | + * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added. |
|
236 | + * @return IniHelper_Section |
|
237 | + */ |
|
238 | 238 | public function addValue(string $name, $value) : IniHelper_Section |
239 | 239 | { |
240 | 240 | // array value? Treat it as duplicate keys. |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | |
300 | - /** |
|
301 | - * Retrieves all lines for the specified variable name. |
|
302 | - * |
|
303 | - * @param string $name |
|
304 | - * @return INILine[] |
|
305 | - */ |
|
300 | + /** |
|
301 | + * Retrieves all lines for the specified variable name. |
|
302 | + * |
|
303 | + * @param string $name |
|
304 | + * @return INILine[] |
|
305 | + */ |
|
306 | 306 | public function getLinesByVariable(string $name) : array |
307 | 307 | { |
308 | 308 | $result = array(); |
@@ -27,9 +27,9 @@ |
||
27 | 27 | protected RequestParam $param; |
28 | 28 | protected bool $isSubvalue = false; |
29 | 29 | |
30 | - /** |
|
31 | - * @var mixed|NULL |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var mixed|NULL |
|
32 | + */ |
|
33 | 33 | protected $value; |
34 | 34 | |
35 | 35 | public function __construct(RequestParam $param, bool $subval) |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | private static bool $simulation = false; |
35 | 35 | private DOMDocument $dom; |
36 | 36 | |
37 | - /** |
|
38 | - * Creates a new XMLHelper instance. |
|
39 | - * |
|
40 | - * @return XMLHelper |
|
41 | - */ |
|
37 | + /** |
|
38 | + * Creates a new XMLHelper instance. |
|
39 | + * |
|
40 | + * @return XMLHelper |
|
41 | + */ |
|
42 | 42 | public static function create() : XMLHelper |
43 | 43 | { |
44 | 44 | $dom = new DOMDocument('1.0', 'UTF-8'); |
@@ -68,38 +68,38 @@ discard block |
||
68 | 68 | return XMLHelper_Converter::fromString($xmlString); |
69 | 69 | } |
70 | 70 | |
71 | - /** |
|
72 | - * Creates a converter from a SimpleXMLElement instance. |
|
73 | - * @param SimpleXMLElement $element |
|
74 | - * @return XMLHelper_Converter |
|
75 | - */ |
|
71 | + /** |
|
72 | + * Creates a converter from a SimpleXMLElement instance. |
|
73 | + * @param SimpleXMLElement $element |
|
74 | + * @return XMLHelper_Converter |
|
75 | + */ |
|
76 | 76 | public static function convertElement(SimpleXMLElement $element) : XMLHelper_Converter |
77 | 77 | { |
78 | 78 | return XMLHelper_Converter::fromElement($element); |
79 | 79 | } |
80 | 80 | |
81 | - /** |
|
82 | - * Creates a converter from a DOMElement instance. |
|
83 | - * @param DOMElement $element |
|
84 | - * @return XMLHelper_Converter |
|
85 | - */ |
|
81 | + /** |
|
82 | + * Creates a converter from a DOMElement instance. |
|
83 | + * @param DOMElement $element |
|
84 | + * @return XMLHelper_Converter |
|
85 | + */ |
|
86 | 86 | public static function convertDOMElement(DOMElement $element) : XMLHelper_Converter |
87 | 87 | { |
88 | 88 | return XMLHelper_Converter::fromDOMElement($element); |
89 | 89 | } |
90 | 90 | |
91 | - /** |
|
92 | - * Creates a new helper using an existing DOMDocument object. |
|
93 | - * @param DOMDocument $dom |
|
94 | - */ |
|
91 | + /** |
|
92 | + * Creates a new helper using an existing DOMDocument object. |
|
93 | + * @param DOMDocument $dom |
|
94 | + */ |
|
95 | 95 | public function __construct(DOMDocument $dom) |
96 | 96 | { |
97 | 97 | $this->dom = $dom; |
98 | 98 | } |
99 | 99 | |
100 | - /** |
|
101 | - * @return DOMDocument |
|
102 | - */ |
|
100 | + /** |
|
101 | + * @return DOMDocument |
|
102 | + */ |
|
103 | 103 | public function getDOM() : DOMDocument |
104 | 104 | { |
105 | 105 | return $this->dom; |
@@ -299,12 +299,12 @@ discard block |
||
299 | 299 | return $root; |
300 | 300 | } |
301 | 301 | |
302 | - /** |
|
303 | - * Escaped the string for use in XML. |
|
304 | - * |
|
305 | - * @param string $string |
|
306 | - * @return string |
|
307 | - */ |
|
302 | + /** |
|
303 | + * Escaped the string for use in XML. |
|
304 | + * |
|
305 | + * @param string $string |
|
306 | + * @return string |
|
307 | + */ |
|
308 | 308 | public function escape(string $string) : string |
309 | 309 | { |
310 | 310 | return preg_replace('#<p>(.*)</p>#isUm', '$1', $string); |
@@ -331,18 +331,18 @@ discard block |
||
331 | 331 | ); |
332 | 332 | } |
333 | 333 | |
334 | - /** |
|
335 | - * Sends the specified XML string to the browser with |
|
336 | - * the correct headers to trigger a download of the XML |
|
337 | - * to a local file. |
|
338 | - * |
|
339 | - * NOTE: Ensure calling exit after this is done, and to |
|
340 | - * not send additional content, which would corrupt the |
|
341 | - * download. |
|
342 | - * |
|
343 | - * @param string $xml |
|
344 | - * @param string $filename |
|
345 | - */ |
|
334 | + /** |
|
335 | + * Sends the specified XML string to the browser with |
|
336 | + * the correct headers to trigger a download of the XML |
|
337 | + * to a local file. |
|
338 | + * |
|
339 | + * NOTE: Ensure calling exit after this is done, and to |
|
340 | + * not send additional content, which would corrupt the |
|
341 | + * download. |
|
342 | + * |
|
343 | + * @param string $xml |
|
344 | + * @param string $filename |
|
345 | + */ |
|
346 | 346 | public static function downloadXML(string $xml, string $filename = 'download.xml') : void |
347 | 347 | { |
348 | 348 | if(!self::$simulation && !headers_sent()) |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | echo $xml; |
354 | 354 | } |
355 | 355 | |
356 | - /** |
|
357 | - * Sends the specified XML string to the browser with |
|
358 | - * the correct headers and terminates the request. |
|
359 | - * |
|
360 | - * @param string $xml |
|
361 | - */ |
|
356 | + /** |
|
357 | + * Sends the specified XML string to the browser with |
|
358 | + * the correct headers and terminates the request. |
|
359 | + * |
|
360 | + * @param string $xml |
|
361 | + */ |
|
362 | 362 | public static function displayXML(string $xml) : void |
363 | 363 | { |
364 | 364 | if(!self::$simulation && !headers_sent()) |
@@ -477,30 +477,30 @@ discard block |
||
477 | 477 | return $this->dom->saveXML(); |
478 | 478 | } |
479 | 479 | |
480 | - /** |
|
481 | - * Creates a new SimpleXML helper instance: this |
|
482 | - * object is useful to work with loading XML strings |
|
483 | - * and files with easy access to any errors that |
|
484 | - * may occurr, since the simplexml functions can be |
|
485 | - * somewhat cryptic. |
|
486 | - * |
|
487 | - * @return XMLHelper_SimpleXML |
|
488 | - */ |
|
480 | + /** |
|
481 | + * Creates a new SimpleXML helper instance: this |
|
482 | + * object is useful to work with loading XML strings |
|
483 | + * and files with easy access to any errors that |
|
484 | + * may occurr, since the simplexml functions can be |
|
485 | + * somewhat cryptic. |
|
486 | + * |
|
487 | + * @return XMLHelper_SimpleXML |
|
488 | + */ |
|
489 | 489 | public static function createSimplexml() : XMLHelper_SimpleXML |
490 | 490 | { |
491 | 491 | return new XMLHelper_SimpleXML(); |
492 | 492 | } |
493 | 493 | |
494 | - /** |
|
495 | - * Converts a string to valid XML: can be a text only string |
|
496 | - * or an HTML string. Returns valid XML code. |
|
497 | - * |
|
498 | - * NOTE: The string may contain custom tags, which are |
|
499 | - * preserved. |
|
500 | - * |
|
501 | - * @param string $string |
|
502 | - * @return string |
|
503 | - */ |
|
494 | + /** |
|
495 | + * Converts a string to valid XML: can be a text only string |
|
496 | + * or an HTML string. Returns valid XML code. |
|
497 | + * |
|
498 | + * NOTE: The string may contain custom tags, which are |
|
499 | + * preserved. |
|
500 | + * |
|
501 | + * @param string $string |
|
502 | + * @return string |
|
503 | + */ |
|
504 | 504 | public static function string2xml(string $string) : string |
505 | 505 | { |
506 | 506 | return XMLHelper_HTMLLoader::loadFragment($string)->fragmentToXML(); |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | protected RequestHelper_Boundaries $boundaries; |
26 | 26 | protected string $transferEncoding = ''; |
27 | 27 | |
28 | - /** |
|
29 | - * @var array<string,string> |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var array<string,string> |
|
30 | + */ |
|
31 | 31 | protected array $dispositionParams = array(); |
32 | 32 | |
33 | 33 | public function __construct(RequestHelper_Boundaries $boundaries, string $content) |
@@ -41,46 +41,46 @@ discard block |
||
41 | 41 | return strlen($this->content); |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * Sets the name of the request parameter. |
|
46 | - * |
|
47 | - * @param string $name |
|
48 | - * @return RequestHelper_Boundaries_Boundary |
|
49 | - */ |
|
44 | + /** |
|
45 | + * Sets the name of the request parameter. |
|
46 | + * |
|
47 | + * @param string $name |
|
48 | + * @return RequestHelper_Boundaries_Boundary |
|
49 | + */ |
|
50 | 50 | public function setName(string $name) : RequestHelper_Boundaries_Boundary |
51 | 51 | { |
52 | 52 | return $this->setDispositionParam('name', $name); |
53 | 53 | } |
54 | 54 | |
55 | - /** |
|
56 | - * Sets the filename to use for the content, if applicable. |
|
57 | - * |
|
58 | - * @param string $fileName |
|
59 | - * @return RequestHelper_Boundaries_Boundary |
|
60 | - */ |
|
55 | + /** |
|
56 | + * Sets the filename to use for the content, if applicable. |
|
57 | + * |
|
58 | + * @param string $fileName |
|
59 | + * @return RequestHelper_Boundaries_Boundary |
|
60 | + */ |
|
61 | 61 | public function setFileName(string $fileName) : RequestHelper_Boundaries_Boundary |
62 | 62 | { |
63 | 63 | return $this->setDispositionParam('filename', $fileName); |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
67 | - * Sets the content type to use for the content. |
|
68 | - * |
|
69 | - * @param string $contentType |
|
70 | - * @return RequestHelper_Boundaries_Boundary |
|
71 | - */ |
|
66 | + /** |
|
67 | + * Sets the content type to use for the content. |
|
68 | + * |
|
69 | + * @param string $contentType |
|
70 | + * @return RequestHelper_Boundaries_Boundary |
|
71 | + */ |
|
72 | 72 | public function setContentType(string $contentType) : RequestHelper_Boundaries_Boundary |
73 | 73 | { |
74 | 74 | $this->contentType = $contentType; |
75 | 75 | return $this; |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * Sets the encoding to specify for the content. |
|
80 | - * |
|
81 | - * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII" |
|
82 | - * @return RequestHelper_Boundaries_Boundary |
|
83 | - */ |
|
78 | + /** |
|
79 | + * Sets the encoding to specify for the content. |
|
80 | + * |
|
81 | + * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII" |
|
82 | + * @return RequestHelper_Boundaries_Boundary |
|
83 | + */ |
|
84 | 84 | public function setContentEncoding(string $encoding) : RequestHelper_Boundaries_Boundary |
85 | 85 | { |
86 | 86 | $this->contentEncoding = $encoding; |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | return $this; |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
104 | - * Renders the mime boundary text. |
|
105 | - * |
|
106 | - * @return string |
|
107 | - */ |
|
103 | + /** |
|
104 | + * Renders the mime boundary text. |
|
105 | + * |
|
106 | + * @return string |
|
107 | + */ |
|
108 | 108 | public function render() : string |
109 | 109 | { |
110 | 110 | $eol = $this->boundaries->getEOL(); |
@@ -31,21 +31,21 @@ discard block |
||
31 | 31 | protected array $info; |
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @param RequestHelper $helper |
|
36 | - * @param array<string,mixed> $info The CURL info array from curl_getinfo(). |
|
37 | - */ |
|
34 | + /** |
|
35 | + * @param RequestHelper $helper |
|
36 | + * @param array<string,mixed> $info The CURL info array from curl_getinfo(). |
|
37 | + */ |
|
38 | 38 | public function __construct(RequestHelper $helper, array $info) |
39 | 39 | { |
40 | 40 | $this->request = $helper; |
41 | 41 | $this->info = $info; |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * Retrieves the request instance that initiated the request. |
|
46 | - * |
|
47 | - * @return RequestHelper |
|
48 | - */ |
|
44 | + /** |
|
45 | + * Retrieves the request instance that initiated the request. |
|
46 | + * |
|
47 | + * @return RequestHelper |
|
48 | + */ |
|
49 | 49 | public function getRequest() : RequestHelper |
50 | 50 | { |
51 | 51 | return $this->request; |
@@ -66,79 +66,79 @@ discard block |
||
66 | 66 | return $this; |
67 | 67 | } |
68 | 68 | |
69 | - /** |
|
70 | - * Whether an error occurred in the request. |
|
71 | - * @return bool |
|
72 | - */ |
|
69 | + /** |
|
70 | + * Whether an error occurred in the request. |
|
71 | + * @return bool |
|
72 | + */ |
|
73 | 73 | public function isError() : bool |
74 | 74 | { |
75 | 75 | return $this->isError; |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * Whether the request timed out. |
|
80 | - * @return bool |
|
81 | - */ |
|
78 | + /** |
|
79 | + * Whether the request timed out. |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | 82 | public function isTimeout() : bool |
83 | 83 | { |
84 | 84 | return $this->errorCode === RequestHelper_CURL::OPERATION_TIMEDOUT; |
85 | 85 | } |
86 | 86 | |
87 | - /** |
|
88 | - * Retrieves the native error message, if an error occurred. |
|
89 | - * @return string |
|
90 | - */ |
|
87 | + /** |
|
88 | + * Retrieves the native error message, if an error occurred. |
|
89 | + * @return string |
|
90 | + */ |
|
91 | 91 | public function getErrorMessage() : string |
92 | 92 | { |
93 | 93 | return $this->errorMessage; |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Retrieves the native CURL error code, if an error occurred. |
|
98 | - * @return int |
|
99 | - * @see RequestHelper_CURL For a list of error codes. |
|
100 | - */ |
|
96 | + /** |
|
97 | + * Retrieves the native CURL error code, if an error occurred. |
|
98 | + * @return int |
|
99 | + * @see RequestHelper_CURL For a list of error codes. |
|
100 | + */ |
|
101 | 101 | public function getErrorCode() : int |
102 | 102 | { |
103 | 103 | return $this->errorCode; |
104 | 104 | } |
105 | 105 | |
106 | - /** |
|
107 | - * Retrieves the full body of the request. |
|
108 | - * |
|
109 | - * @return string |
|
110 | - */ |
|
106 | + /** |
|
107 | + * Retrieves the full body of the request. |
|
108 | + * |
|
109 | + * @return string |
|
110 | + */ |
|
111 | 111 | public function getRequestBody() : string |
112 | 112 | { |
113 | 113 | return $this->request->getBody(); |
114 | 114 | } |
115 | 115 | |
116 | - /** |
|
117 | - * Retrieves the body of the response, if any. |
|
118 | - * |
|
119 | - * @return string |
|
120 | - */ |
|
116 | + /** |
|
117 | + * Retrieves the body of the response, if any. |
|
118 | + * |
|
119 | + * @return string |
|
120 | + */ |
|
121 | 121 | public function getResponseBody() : string |
122 | 122 | { |
123 | 123 | return $this->body; |
124 | 124 | } |
125 | 125 | |
126 | - /** |
|
127 | - * The response HTTP code. |
|
128 | - * |
|
129 | - * @return int The code, or 0 if none was sent (on error). |
|
130 | - */ |
|
126 | + /** |
|
127 | + * The response HTTP code. |
|
128 | + * |
|
129 | + * @return int The code, or 0 if none was sent (on error). |
|
130 | + */ |
|
131 | 131 | public function getCode() : int |
132 | 132 | { |
133 | 133 | return (int)$this->getInfoKey('http_code'); |
134 | 134 | } |
135 | 135 | |
136 | - /** |
|
137 | - * Retrieves the actual headers that were sent in the request: |
|
138 | - * one header by entry in the indexed array. |
|
139 | - * |
|
140 | - * @return string[] |
|
141 | - */ |
|
136 | + /** |
|
137 | + * Retrieves the actual headers that were sent in the request: |
|
138 | + * one header by entry in the indexed array. |
|
139 | + * |
|
140 | + * @return string[] |
|
141 | + */ |
|
142 | 142 | public function getHeaders() : array |
143 | 143 | { |
144 | 144 | return ConvertHelper::explodeTrim("\n", $this->getInfoKey('request_header')); |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | |
38 | 38 | public const ERROR_INVALID_SERIALIZED_DATA = 56301; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | 43 | protected $string; |
44 | 44 | |
45 | - /** |
|
46 | - * @var mixed |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var mixed |
|
47 | + */ |
|
48 | 48 | protected $value; |
49 | 49 | |
50 | - /** |
|
51 | - * @var string |
|
52 | - */ |
|
50 | + /** |
|
51 | + * @var string |
|
52 | + */ |
|
53 | 53 | protected $type; |
54 | 54 | |
55 | 55 | /** |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | return new VariableInfo(null, $serialized); |
107 | 107 | } |
108 | 108 | |
109 | - /** |
|
110 | - * Parses a previously serialized data set to restore the |
|
111 | - * variable information from it. |
|
112 | - * |
|
113 | - * @param array<mixed> $serialized |
|
114 | - * @throws BaseException |
|
115 | - * |
|
116 | - * @see VariableInfo::ERROR_INVALID_SERIALIZED_DATA |
|
117 | - */ |
|
109 | + /** |
|
110 | + * Parses a previously serialized data set to restore the |
|
111 | + * variable information from it. |
|
112 | + * |
|
113 | + * @param array<mixed> $serialized |
|
114 | + * @throws BaseException |
|
115 | + * |
|
116 | + * @see VariableInfo::ERROR_INVALID_SERIALIZED_DATA |
|
117 | + */ |
|
118 | 118 | protected function parseSerialized(array $serialized) : void |
119 | 119 | { |
120 | 120 | if(!isset($serialized['string'], $serialized['type'], $serialized['options'])) |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | return $this->value; |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
167 | - * The variable type - this is the same string that |
|
168 | - * is returned by the PHP function `gettype`. |
|
169 | - * |
|
170 | - * @return string |
|
171 | - */ |
|
166 | + /** |
|
167 | + * The variable type - this is the same string that |
|
168 | + * is returned by the PHP function `gettype`. |
|
169 | + * |
|
170 | + * @return string |
|
171 | + */ |
|
172 | 172 | public function getType() : string |
173 | 173 | { |
174 | 174 | return $this->type; |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | ); |
186 | 186 | } |
187 | 187 | |
188 | - /** |
|
189 | - * Whether to prepend the variable type before the value, |
|
190 | - * like the var_dump function. Example: <code>string "Some text"</code>. |
|
191 | - * |
|
192 | - * @param bool $enable |
|
193 | - * @return VariableInfo |
|
194 | - */ |
|
188 | + /** |
|
189 | + * Whether to prepend the variable type before the value, |
|
190 | + * like the var_dump function. Example: <code>string "Some text"</code>. |
|
191 | + * |
|
192 | + * @param bool $enable |
|
193 | + * @return VariableInfo |
|
194 | + */ |
|
195 | 195 | public function enableType(bool $enable=true) : VariableInfo |
196 | 196 | { |
197 | 197 | return $this->setOption('prepend-type', $enable); |