@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param string[] $paths |
37 | 37 | * @throws FileHelper_Exception |
38 | 38 | */ |
39 | - public function __construct(array $paths=array()) |
|
39 | + public function __construct(array $paths = array()) |
|
40 | 40 | { |
41 | 41 | $this->addPaths($paths); |
42 | 42 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function addPaths(array $paths) : PathsReducer |
51 | 51 | { |
52 | - foreach($paths as $path) { |
|
52 | + foreach ($paths as $path) { |
|
53 | 53 | $this->addPath($path); |
54 | 54 | } |
55 | 55 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | $path = FileHelper::normalizePath($path); |
68 | 68 | |
69 | - if(!in_array($path, $this->paths, true)) { |
|
69 | + if (!in_array($path, $this->paths, true)) { |
|
70 | 70 | $this->paths[] = $path; |
71 | 71 | } |
72 | 72 | |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | { |
84 | 84 | $split = $this->splitPaths(); |
85 | 85 | |
86 | - if(empty($split)) { |
|
86 | + if (empty($split)) { |
|
87 | 87 | return array(); |
88 | 88 | } |
89 | 89 | |
90 | - while($this->shiftPart($split) === true) {} |
|
90 | + while ($this->shiftPart($split) === true) {} |
|
91 | 91 | |
92 | 92 | return $this->joinPaths($split); |
93 | 93 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $result = array(); |
102 | 102 | |
103 | 103 | foreach ($split as $entry) { |
104 | - if(!empty($entry)) { |
|
104 | + if (!empty($entry)) { |
|
105 | 105 | $result[] = implode('/', $entry); |
106 | 106 | } |
107 | 107 | } |
@@ -118,22 +118,22 @@ discard block |
||
118 | 118 | $current = null; |
119 | 119 | $result = array(); |
120 | 120 | |
121 | - foreach($split as $entry) |
|
121 | + foreach ($split as $entry) |
|
122 | 122 | { |
123 | - if(empty($entry)) { |
|
123 | + if (empty($entry)) { |
|
124 | 124 | return false; |
125 | 125 | } |
126 | 126 | |
127 | 127 | $part = array_shift($entry); |
128 | - if(empty($entry)) { |
|
128 | + if (empty($entry)) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | |
132 | - if($current === null) { |
|
132 | + if ($current === null) { |
|
133 | 133 | $current = $part; |
134 | 134 | } |
135 | 135 | |
136 | - if($part !== $current) { |
|
136 | + if ($part !== $current) { |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | { |
153 | 153 | $split = array(); |
154 | 154 | |
155 | - foreach($this->paths as $path) { |
|
155 | + foreach ($this->paths as $path) { |
|
156 | 156 | $entry = ConvertHelper::explodeTrim('/', $path); |
157 | - if(!empty($entry)) { |
|
157 | + if (!empty($entry)) { |
|
158 | 158 | $split[] = $entry; |
159 | 159 | } |
160 | 160 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | private function convertEncoding(string $contents) : string |
126 | 126 | { |
127 | - if(!empty($this->targetEncoding)) |
|
127 | + if (!empty($this->targetEncoding)) |
|
128 | 128 | { |
129 | 129 | return mb_convert_encoding( |
130 | 130 | $contents, |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | { |
147 | 147 | $options = null; |
148 | 148 | |
149 | - if($pretty) |
|
149 | + if ($pretty) |
|
150 | 150 | { |
151 | 151 | $options = JSON_PRETTY_PRINT; |
152 | 152 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function setTimeout(int $timeout) : FileDownloader |
42 | 42 | { |
43 | - if($timeout > 0) |
|
43 | + if ($timeout > 0) |
|
44 | 44 | { |
45 | 45 | $this->timeout = $timeout; |
46 | 46 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param bool $enabled |
53 | 53 | * @return FileDownloader |
54 | 54 | */ |
55 | - public function setSSLEnabled(bool $enabled=true) : FileDownloader |
|
55 | + public function setSSLEnabled(bool $enabled = true) : FileDownloader |
|
56 | 56 | { |
57 | 57 | $this->SSLEnabled = $enabled; |
58 | 58 | return $this; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | $output = curl_exec($ch); |
75 | 75 | |
76 | - if($output === false) |
|
76 | + if ($output === false) |
|
77 | 77 | { |
78 | 78 | throw new FileHelper_Exception( |
79 | 79 | 'Unable to open URL', |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | curl_close($ch); |
90 | 90 | |
91 | - if(is_string($output)) |
|
91 | + if (is_string($output)) |
|
92 | 92 | { |
93 | 93 | return $output; |
94 | 94 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | { |
109 | 109 | $ch = curl_init(); |
110 | 110 | |
111 | - if(!is_resource($ch)) |
|
111 | + if (!is_resource($ch)) |
|
112 | 112 | { |
113 | 113 | throw new FileHelper_Exception( |
114 | 114 | 'Could not initialize a new cURL instance.', |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
126 | 126 | curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); |
127 | 127 | |
128 | - if(!$this->SSLEnabled) |
|
128 | + if (!$this->SSLEnabled) |
|
129 | 129 | { |
130 | 130 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
131 | 131 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @var array<string,string>|NULL |
64 | 64 | * @see URLInfo::getTypeLabel() |
65 | 65 | */ |
66 | - protected static ?array $typeLabels = null; |
|
66 | + protected static ? array $typeLabels = null; |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @var bool |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * @param bool $enabled |
127 | 127 | * @return URLInfo |
128 | 128 | */ |
129 | - public function setUTFEncoding(bool $enabled=true) : URLInfo |
|
129 | + public function setUTFEncoding(bool $enabled = true) : URLInfo |
|
130 | 130 | { |
131 | - if($this->encodeUTFChars !== $enabled) |
|
131 | + if ($this->encodeUTFChars !== $enabled) |
|
132 | 132 | { |
133 | 133 | $this->encodeUTFChars = $enabled; |
134 | 134 | $this->parse(); // re-parse the URL to apply the changes |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | { |
233 | 233 | $port = $this->getInfoKey('port'); |
234 | 234 | |
235 | - if(!empty($port)) { |
|
235 | + if (!empty($port)) { |
|
236 | 236 | return (int)$port; |
237 | 237 | } |
238 | 238 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | |
313 | 313 | protected function getInfoKey(string $name) : string |
314 | 314 | { |
315 | - if(isset($this->info[$name])) { |
|
315 | + if (isset($this->info[$name])) { |
|
316 | 316 | return (string)$this->info[$name]; |
317 | 317 | } |
318 | 318 | |
@@ -341,13 +341,13 @@ discard block |
||
341 | 341 | return $this->normalize(false); |
342 | 342 | } |
343 | 343 | |
344 | - protected function normalize(bool $auth=true) : string |
|
344 | + protected function normalize(bool $auth = true) : string |
|
345 | 345 | { |
346 | - if(!$this->isValid()) { |
|
346 | + if (!$this->isValid()) { |
|
347 | 347 | return ''; |
348 | 348 | } |
349 | 349 | |
350 | - if(!isset($this->normalizer)) { |
|
350 | + if (!isset($this->normalizer)) { |
|
351 | 351 | $this->normalizer = new URLInfo_Normalizer($this); |
352 | 352 | } |
353 | 353 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | */ |
378 | 378 | public function getHighlighted() : string |
379 | 379 | { |
380 | - if(!$this->isValid()) { |
|
380 | + if (!$this->isValid()) { |
|
381 | 381 | return ''; |
382 | 382 | } |
383 | 383 | |
@@ -419,14 +419,14 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function getParams() : array |
421 | 421 | { |
422 | - if(!$this->paramExclusion || empty($this->excludedParams)) { |
|
422 | + if (!$this->paramExclusion || empty($this->excludedParams)) { |
|
423 | 423 | return $this->info['params']; |
424 | 424 | } |
425 | 425 | |
426 | 426 | $keep = array(); |
427 | - foreach($this->info['params'] as $name => $value) |
|
427 | + foreach ($this->info['params'] as $name => $value) |
|
428 | 428 | { |
429 | - if(!isset($this->excludedParams[$name])) { |
|
429 | + if (!isset($this->excludedParams[$name])) { |
|
430 | 430 | $keep[$name] = $value; |
431 | 431 | } |
432 | 432 | } |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | */ |
453 | 453 | public function getParam(string $name) : string |
454 | 454 | { |
455 | - if(isset($this->info['params'][$name])) { |
|
455 | + if (isset($this->info['params'][$name])) { |
|
456 | 456 | return $this->info['params'][$name]; |
457 | 457 | } |
458 | 458 | |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
470 | 470 | * @return URLInfo |
471 | 471 | */ |
472 | - public function excludeParam(string $name, string $reason='') : URLInfo |
|
472 | + public function excludeParam(string $name, string $reason = '') : URLInfo |
|
473 | 473 | { |
474 | - if(!isset($this->excludedParams[$name])) |
|
474 | + if (!isset($this->excludedParams[$name])) |
|
475 | 475 | { |
476 | 476 | $this->excludedParams[$name] = $reason; |
477 | 477 | $this->setParamExclusion(); |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | |
498 | 498 | public function getTypeLabel() : string |
499 | 499 | { |
500 | - if(!isset(self::$typeLabels)) |
|
500 | + if (!isset(self::$typeLabels)) |
|
501 | 501 | { |
502 | 502 | self::$typeLabels = array( |
503 | 503 | self::TYPE_EMAIL => t('Email'), |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | |
510 | 510 | $type = $this->getType(); |
511 | 511 | |
512 | - if(!isset(self::$typeLabels[$type])) |
|
512 | + if (!isset(self::$typeLabels[$type])) |
|
513 | 513 | { |
514 | 514 | throw new BaseException( |
515 | 515 | sprintf('Unknown URL type label for type [%s].', $type), |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * @param bool $highlight |
530 | 530 | * @return URLInfo |
531 | 531 | */ |
532 | - public function setHighlightExcluded(bool $highlight=true) : URLInfo |
|
532 | + public function setHighlightExcluded(bool $highlight = true) : URLInfo |
|
533 | 533 | { |
534 | 534 | $this->highlightExcluded = $highlight; |
535 | 535 | return $this; |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | * @see URLInfo::isParamExclusionEnabled() |
579 | 579 | * @see URLInfo::setHighlightExcluded() |
580 | 580 | */ |
581 | - public function setParamExclusion(bool $enabled=true) : URLInfo |
|
581 | + public function setParamExclusion(bool $enabled = true) : URLInfo |
|
582 | 582 | { |
583 | 583 | $this->paramExclusion = $enabled; |
584 | 584 | return $this; |
@@ -604,13 +604,13 @@ discard block |
||
604 | 604 | */ |
605 | 605 | public function containsExcludedParams() : bool |
606 | 606 | { |
607 | - if(empty($this->excludedParams)) { |
|
607 | + if (empty($this->excludedParams)) { |
|
608 | 608 | return false; |
609 | 609 | } |
610 | 610 | |
611 | 611 | $names = array_keys($this->info['params']); |
612 | - foreach($names as $name) { |
|
613 | - if(isset($this->excludedParams[$name])) { |
|
612 | + foreach ($names as $name) { |
|
613 | + if (isset($this->excludedParams[$name])) { |
|
614 | 614 | return true; |
615 | 615 | } |
616 | 616 | } |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | |
627 | 627 | public function offsetSet($offset, $value) |
628 | 628 | { |
629 | - if(in_array($offset, $this->infoKeys)) { |
|
629 | + if (in_array($offset, $this->infoKeys)) { |
|
630 | 630 | $this->info[$offset] = $value; |
631 | 631 | } |
632 | 632 | } |
@@ -643,11 +643,11 @@ discard block |
||
643 | 643 | |
644 | 644 | public function offsetGet($offset) |
645 | 645 | { |
646 | - if($offset === 'port') { |
|
646 | + if ($offset === 'port') { |
|
647 | 647 | return $this->getPort(); |
648 | 648 | } |
649 | 649 | |
650 | - if(in_array($offset, $this->infoKeys)) { |
|
650 | + if (in_array($offset, $this->infoKeys)) { |
|
651 | 651 | return $this->getInfoKey($offset); |
652 | 652 | } |
653 | 653 | |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | * @return bool |
683 | 683 | * @throws BaseException |
684 | 684 | */ |
685 | - public function tryConnect(bool $verifySSL=true) : bool |
|
685 | + public function tryConnect(bool $verifySSL = true) : bool |
|
686 | 686 | { |
687 | 687 | return $this->createConnectionTester() |
688 | 688 | ->setVerifySSL($verifySSL) |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | */ |
726 | 726 | public function removeParam(string $param) : URLInfo |
727 | 727 | { |
728 | - if(isset($this->info['params'][$param])) |
|
728 | + if (isset($this->info['params'][$param])) |
|
729 | 729 | { |
730 | 730 | unset($this->info['params'][$param]); |
731 | 731 | } |
@@ -74,7 +74,7 @@ |
||
74 | 74 | * @param bool $enabled |
75 | 75 | * @return $this |
76 | 76 | */ |
77 | - public function prop(string $name, bool $enabled=true) : self |
|
77 | + public function prop(string $name, bool $enabled = true) : self |
|
78 | 78 | { |
79 | 79 | $this->getAttributes()->prop($name, $enabled); |
80 | 80 | return $this; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function addClass($name) |
43 | 43 | { |
44 | - if(!in_array($name, $this->classes, true)) { |
|
44 | + if (!in_array($name, $this->classes, true)) { |
|
45 | 45 | $this->classes[] = $name; |
46 | 46 | } |
47 | 47 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function addClasses(array $names) : self |
56 | 56 | { |
57 | - foreach($names as $name) { |
|
57 | + foreach ($names as $name) { |
|
58 | 58 | $this->addClass($name); |
59 | 59 | } |
60 | 60 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | { |
75 | 75 | $idx = array_search($name, $this->classes, true); |
76 | 76 | |
77 | - if($idx !== false) { |
|
77 | + if ($idx !== false) { |
|
78 | 78 | unset($this->classes[$idx]); |
79 | 79 | sort($this->classes); |
80 | 80 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function classesToAttribute() : string |
110 | 110 | { |
111 | - if(!empty($this->classes)) |
|
111 | + if (!empty($this->classes)) |
|
112 | 112 | { |
113 | 113 | return sprintf( |
114 | 114 | ' class="%s" ', |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function setOption(string $name, $value) : self |
43 | 43 | { |
44 | - if(!isset($this->options)) { |
|
44 | + if (!isset($this->options)) { |
|
45 | 45 | $this->options = $this->getDefaultOptions(); |
46 | 46 | } |
47 | 47 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function setOptions(array $options) : self |
60 | 60 | { |
61 | - foreach($options as $name => $value) { |
|
61 | + foreach ($options as $name => $value) { |
|
62 | 62 | $this->setOption($name, $value); |
63 | 63 | } |
64 | 64 | |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | * @param mixed $default The default value to return if the option does not exist. |
76 | 76 | * @return mixed |
77 | 77 | */ |
78 | - public function getOption(string $name, $default=null) |
|
78 | + public function getOption(string $name, $default = null) |
|
79 | 79 | { |
80 | - if(!isset($this->options)) |
|
80 | + if (!isset($this->options)) |
|
81 | 81 | { |
82 | 82 | $this->options = $this->getDefaultOptions(); |
83 | 83 | } |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * @param string $default Used if the option does not exist, is invalid, or empty. |
96 | 96 | * @return string |
97 | 97 | */ |
98 | - public function getStringOption(string $name, string $default='') : string |
|
98 | + public function getStringOption(string $name, string $default = '') : string |
|
99 | 99 | { |
100 | 100 | $value = $this->getOption($name, false); |
101 | 101 | |
102 | - if((is_string($value) || is_numeric($value)) && !empty($value)) { |
|
102 | + if ((is_string($value) || is_numeric($value)) && !empty($value)) { |
|
103 | 103 | return (string)$value; |
104 | 104 | } |
105 | 105 | |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @param bool $default |
117 | 117 | * @return bool |
118 | 118 | */ |
119 | - public function getBoolOption(string $name, bool $default=false) : bool |
|
119 | + public function getBoolOption(string $name, bool $default = false) : bool |
|
120 | 120 | { |
121 | - if($this->getOption($name) === true) |
|
121 | + if ($this->getOption($name) === true) |
|
122 | 122 | { |
123 | 123 | return true; |
124 | 124 | } |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | * @param int $default |
136 | 136 | * @return int |
137 | 137 | */ |
138 | - public function getIntOption(string $name, int $default=0) : int |
|
138 | + public function getIntOption(string $name, int $default = 0) : int |
|
139 | 139 | { |
140 | 140 | $value = $this->getOption($name); |
141 | - if(ConvertHelper::isInteger($value)) { |
|
141 | + if (ConvertHelper::isInteger($value)) { |
|
142 | 142 | return (int)$value; |
143 | 143 | } |
144 | 144 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | public function getArrayOption(string $name) : array |
157 | 157 | { |
158 | 158 | $val = $this->getOption($name); |
159 | - if(is_array($val)) { |
|
159 | + if (is_array($val)) { |
|
160 | 160 | return $val; |
161 | 161 | } |
162 | 162 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function hasOption(string $name) : bool |
174 | 174 | { |
175 | - if(!isset($this->options)) { |
|
175 | + if (!isset($this->options)) { |
|
176 | 176 | $this->options = $this->getDefaultOptions(); |
177 | 177 | } |
178 | 178 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function getOptions() : array |
188 | 188 | { |
189 | - if(!isset($this->options)) { |
|
189 | + if (!isset($this->options)) { |
|
190 | 190 | $this->options = $this->getDefaultOptions(); |
191 | 191 | } |
192 | 192 |
@@ -56,12 +56,12 @@ |
||
56 | 56 | */ |
57 | 57 | public static function value2string($value) : string |
58 | 58 | { |
59 | - if($value === true) |
|
59 | + if ($value === true) |
|
60 | 60 | { |
61 | 61 | return 'true'; |
62 | 62 | } |
63 | 63 | |
64 | - if($value === false) |
|
64 | + if ($value === false) |
|
65 | 65 | { |
66 | 66 | return 'false'; |
67 | 67 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | * @param bool $enabled |
54 | 54 | * @return $this |
55 | 55 | */ |
56 | - public function prop(string $name, bool $enabled=true) : self; |
|
56 | + public function prop(string $name, bool $enabled = true) : self; |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @param string $name |