@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param mixed $default The default value to return if the option does not exist. |
46 | 46 | * @return mixed |
47 | 47 | */ |
48 | - public function getOption(string $name, $default=null); |
|
48 | + public function getOption(string $name, $default = null); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @param string $name |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getArrayOption(string $name) : array; |
55 | 55 | |
56 | - public function getIntOption(string $name, int $default=0) : int; |
|
56 | + public function getIntOption(string $name, int $default = 0) : int; |
|
57 | 57 | |
58 | - public function getBoolOption(string $name, bool $default=false) : bool; |
|
58 | + public function getBoolOption(string $name, bool $default = false) : bool; |
|
59 | 59 | |
60 | - public function getStringOption(string $name, string $default='') : string; |
|
60 | + public function getStringOption(string $name, string $default = '') : string; |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Sets a collection of options at once, from an |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | public function addLimitParam(string $name) : Request_URLComparer |
83 | 83 | { |
84 | - if(!in_array($name, $this->limitParams, true)) |
|
84 | + if (!in_array($name, $this->limitParams, true)) |
|
85 | 85 | { |
86 | 86 | $this->limitParams[] = $name; |
87 | 87 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function addLimitParams(array $names) : Request_URLComparer |
97 | 97 | { |
98 | - foreach($names as $name) |
|
98 | + foreach ($names as $name) |
|
99 | 99 | { |
100 | 100 | $this->addLimitParam($name); |
101 | 101 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | return $this; |
104 | 104 | } |
105 | 105 | |
106 | - public function setIgnoreFragment(bool $ignore=true) : Request_URLComparer |
|
106 | + public function setIgnoreFragment(bool $ignore = true) : Request_URLComparer |
|
107 | 107 | { |
108 | 108 | $this->ignoreFragment = $ignore; |
109 | 109 | return $this; |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | 'query' |
127 | 127 | ); |
128 | 128 | |
129 | - if(!$this->ignoreFragment) { |
|
129 | + if (!$this->ignoreFragment) { |
|
130 | 130 | $keys[] = 'fragment'; |
131 | 131 | } |
132 | 132 | |
133 | - foreach($keys as $key) |
|
133 | + foreach ($keys as $key) |
|
134 | 134 | { |
135 | - if(!$this->compareKey($key)) { |
|
135 | + if (!$this->compareKey($key)) { |
|
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | $filter = 'filter_'.$key; |
149 | 149 | |
150 | - if(method_exists($this, $filter)) |
|
150 | + if (method_exists($this, $filter)) |
|
151 | 151 | { |
152 | 152 | $sVal = $this->$filter($sVal); |
153 | 153 | $tVal = $this->$filter($tVal); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | protected function filter_path(string $path) : string |
160 | 160 | { |
161 | 161 | // fix double slashes in URLs |
162 | - while(strpos($path, '//') !== false) |
|
162 | + while (strpos($path, '//') !== false) |
|
163 | 163 | { |
164 | 164 | $path = str_replace('//', '/', $path); |
165 | 165 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | protected function filter_query(string $query) : string |
171 | 171 | { |
172 | - if(empty($query)) { |
|
172 | + if (empty($query)) { |
|
173 | 173 | return ''; |
174 | 174 | } |
175 | 175 | |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | */ |
189 | 189 | protected function limitParams(array $params) : array |
190 | 190 | { |
191 | - if(empty($this->limitParams)) { |
|
191 | + if (empty($this->limitParams)) { |
|
192 | 192 | return $params; |
193 | 193 | } |
194 | 194 | |
195 | 195 | $keep = array(); |
196 | 196 | |
197 | - foreach($this->limitParams as $name) |
|
197 | + foreach ($this->limitParams as $name) |
|
198 | 198 | { |
199 | - if(isset($params[$name])) { |
|
199 | + if (isset($params[$name])) { |
|
200 | 200 | $keep[$name] = $params[$name]; |
201 | 201 | } |
202 | 202 | } |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | * @param bool $forceNew |
13 | 13 | * @return NumberInfo |
14 | 14 | */ |
15 | -function parseNumber($value, bool $forceNew=false) |
|
15 | +function parseNumber($value, bool $forceNew = false) |
|
16 | 16 | { |
17 | - if($value instanceof NumberInfo && $forceNew !== true) { |
|
17 | + if ($value instanceof NumberInfo && $forceNew !== true) { |
|
18 | 18 | return $value; |
19 | 19 | } |
20 | 20 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $args = func_get_args(); |
110 | 110 | |
111 | 111 | // is the localization package installed? |
112 | - if(function_exists('\AppLocalize\t')) |
|
112 | + if (function_exists('\AppLocalize\t')) |
|
113 | 113 | { |
114 | 114 | return call_user_func_array('\AppLocalize\t', $args); |
115 | 115 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param bool $initial The initial boolean value to use. |
125 | 125 | * @return Value_Bool |
126 | 126 | */ |
127 | -function valBool(bool $initial=false) : Value_Bool |
|
127 | +function valBool(bool $initial = false) : Value_Bool |
|
128 | 128 | { |
129 | 129 | return new Value_Bool($initial); |
130 | 130 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param bool $initial |
138 | 138 | * @return Value_Bool_True |
139 | 139 | */ |
140 | -function valBoolTrue(bool $initial=false) : Value_Bool_True |
|
140 | +function valBoolTrue(bool $initial = false) : Value_Bool_True |
|
141 | 141 | { |
142 | 142 | return new Value_Bool_True($initial); |
143 | 143 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param bool $initial |
151 | 151 | * @return Value_Bool_False |
152 | 152 | */ |
153 | -function valBoolFalse(bool $initial=true) : Value_Bool_False |
|
153 | +function valBoolFalse(bool $initial = true) : Value_Bool_False |
|
154 | 154 | { |
155 | 155 | return new Value_Bool_False($initial); |
156 | 156 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | */ |
182 | 182 | function init() : void |
183 | 183 | { |
184 | - if(!class_exists('\AppLocalize\Localization')) { |
|
184 | + if (!class_exists('\AppLocalize\Localization')) { |
|
185 | 185 | return; |
186 | 186 | } |
187 | 187 |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | public static function detectMimeType(string $fileName) : ?string |
208 | 208 | { |
209 | 209 | $ext = self::getExtension($fileName); |
210 | - if(empty($ext)) { |
|
210 | + if (empty($ext)) { |
|
211 | 211 | return null; |
212 | 212 | } |
213 | 213 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
248 | 248 | * @see FileHelper::ERROR_UNKNOWN_FILE_MIME_TYPE |
249 | 249 | */ |
250 | - public static function sendFile(string $filePath, ?string $fileName = null, bool $asAttachment=true) : void |
|
250 | + public static function sendFile(string $filePath, ?string $fileName = null, bool $asAttachment = true) : void |
|
251 | 251 | { |
252 | 252 | self::getFileInfo($filePath)->getDownloader()->send($fileName, $asAttachment); |
253 | 253 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @throws FileHelper_Exception |
265 | 265 | * @see FileHelper::ERROR_CANNOT_OPEN_URL |
266 | 266 | */ |
267 | - public static function downloadFile(string $url, int $timeout=0, bool $SSLEnabled=false) : string |
|
267 | + public static function downloadFile(string $url, int $timeout = 0, bool $SSLEnabled = false) : string |
|
268 | 268 | { |
269 | 269 | return FileDownloader::factory($url) |
270 | 270 | ->setTimeout($timeout) |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | { |
300 | 300 | $info = self::getPathInfo($pathOrDirIterator); |
301 | 301 | |
302 | - if($info instanceof FileInfo) |
|
302 | + if ($info instanceof FileInfo) |
|
303 | 303 | { |
304 | 304 | return $info->getExtension($lowercase); |
305 | 305 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | { |
324 | 324 | $info = self::getPathInfo($pathOrDirIterator); |
325 | 325 | |
326 | - if($extension === true || $info instanceof FolderInfo) |
|
326 | + if ($extension === true || $info instanceof FolderInfo) |
|
327 | 327 | { |
328 | 328 | return $info->getName(); |
329 | 329 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE |
345 | 345 | * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE |
346 | 346 | */ |
347 | - public static function parseJSONFile(string $file, string $targetEncoding='', $sourceEncoding=null) : array |
|
347 | + public static function parseJSONFile(string $file, string $targetEncoding = '', $sourceEncoding = null) : array |
|
348 | 348 | { |
349 | 349 | return JSONFile::factory(self::getFileInfo($file)) |
350 | 350 | ->setTargetEncoding($targetEncoding) |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | * @throws FileHelper_Exception |
398 | 398 | * @see FileHelper::createFileFinder() |
399 | 399 | */ |
400 | - public static function findHTMLFiles(string $targetFolder, array $options=array()) : array |
|
400 | + public static function findHTMLFiles(string $targetFolder, array $options = array()) : array |
|
401 | 401 | { |
402 | 402 | return self::findFiles($targetFolder, array('html'), $options); |
403 | 403 | } |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @throws FileHelper_Exception |
417 | 417 | * @see FileHelper::createFileFinder() |
418 | 418 | */ |
419 | - public static function findPHPFiles(string $targetFolder, array $options=array()) : array |
|
419 | + public static function findPHPFiles(string $targetFolder, array $options = array()) : array |
|
420 | 420 | { |
421 | 421 | return self::findFiles($targetFolder, array('php'), $options); |
422 | 422 | } |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * @see FileHelper::createFileFinder() |
439 | 439 | * @deprecated Use the file finder instead. |
440 | 440 | */ |
441 | - public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array |
|
441 | + public static function findFiles($targetFolder, array $extensions = array(), array $options = array()) : array |
|
442 | 442 | { |
443 | 443 | $finder = self::createFileFinder($targetFolder); |
444 | 444 | |
@@ -448,16 +448,16 @@ discard block |
||
448 | 448 | |
449 | 449 | $finder->setPathmodeStrip(); |
450 | 450 | |
451 | - if(isset($options['relative-path']) && $options['relative-path'] === true) |
|
451 | + if (isset($options['relative-path']) && $options['relative-path'] === true) |
|
452 | 452 | { |
453 | 453 | $finder->setPathmodeRelative(); |
454 | 454 | } |
455 | - else if(isset($options['absolute-path']) && $options['absolute-path'] === true) |
|
455 | + else if (isset($options['absolute-path']) && $options['absolute-path'] === true) |
|
456 | 456 | { |
457 | 457 | $finder->setPathmodeAbsolute(); |
458 | 458 | } |
459 | 459 | |
460 | - if(isset($options['strip-extension'])) |
|
460 | + if (isset($options['strip-extension'])) |
|
461 | 461 | { |
462 | 462 | $finder->stripExtensions(); |
463 | 463 | } |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * @param bool $keepPath Whether to keep the path component, if any. Default PHP pathinfo behavior is not to. |
476 | 476 | * @return string |
477 | 477 | */ |
478 | - public static function removeExtension(string $filename, bool $keepPath=false) : string |
|
478 | + public static function removeExtension(string $filename, bool $keepPath = false) : string |
|
479 | 479 | { |
480 | 480 | return self::getFileInfo($filename)->removeExtension($keepPath); |
481 | 481 | } |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | |
488 | 488 | public static function createUnicodeHandling() : UnicodeHandling |
489 | 489 | { |
490 | - if(!isset(self::$unicodeHandling)) |
|
490 | + if (!isset(self::$unicodeHandling)) |
|
491 | 491 | { |
492 | 492 | self::$unicodeHandling = new UnicodeHandling(); |
493 | 493 | } |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
521 | 521 | * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
522 | 522 | */ |
523 | - public static function saveAsJSON($data, string $file, bool $pretty=false) : void |
|
523 | + public static function saveAsJSON($data, string $file, bool $pretty = false) : void |
|
524 | 524 | { |
525 | 525 | JSONFile::factory(self::getFileInfo($file)) |
526 | 526 | ->putData($data, $pretty); |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
539 | 539 | * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
540 | 540 | */ |
541 | - public static function saveFile(string $filePath, string $content='') : void |
|
541 | + public static function saveFile(string $filePath, string $content = '') : void |
|
542 | 542 | { |
543 | 543 | self::getFileInfo($filePath)->putContents($content); |
544 | 544 | } |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | */ |
582 | 582 | public static function checkPHPFileSyntax(string $path) |
583 | 583 | { |
584 | - if(!self::canMakePHPCalls()) { |
|
584 | + if (!self::canMakePHPCalls()) { |
|
585 | 585 | return true; |
586 | 586 | } |
587 | 587 | |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | // when the validation is successful, the first entry |
593 | 593 | // in the array contains the success message. When it |
594 | 594 | // is invalid, the first entry is always empty. |
595 | - if(!empty($output[0])) { |
|
595 | + if (!empty($output[0])) { |
|
596 | 596 | return true; |
597 | 597 | } |
598 | 598 | |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | public static function getModifiedDate(string $path) : ?DateTime |
614 | 614 | { |
615 | 615 | $time = filemtime($path); |
616 | - if($time === false) { |
|
616 | + if ($time === false) { |
|
617 | 617 | return null; |
618 | 618 | } |
619 | 619 | |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | * @param int $depth The folder depth to reduce the path to |
675 | 675 | * @return string |
676 | 676 | */ |
677 | - public static function relativizePathByDepth(string $path, int $depth=2) : string |
|
677 | + public static function relativizePathByDepth(string $path, int $depth = 2) : string |
|
678 | 678 | { |
679 | 679 | return PathRelativizer::relativizeByDepth($path, $depth); |
680 | 680 | } |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
714 | 714 | * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND |
715 | 715 | */ |
716 | - public static function requireFileExists($path, ?int $errorCode=null) : string |
|
716 | + public static function requireFileExists($path, ?int $errorCode = null) : string |
|
717 | 717 | { |
718 | 718 | return self::getPathInfo($path) |
719 | 719 | ->requireIsFile() |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | * @return string |
728 | 728 | * @throws FileHelper_Exception |
729 | 729 | */ |
730 | - public static function requireFileReadable(string $path, ?int $errorCode=null) : string |
|
730 | + public static function requireFileReadable(string $path, ?int $errorCode = null) : string |
|
731 | 731 | { |
732 | 732 | return self::getPathInfo($path) |
733 | 733 | ->requireIsFile() |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
817 | 817 | * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES |
818 | 818 | */ |
819 | - public static function readLines(string $filePath, int $amount=0) : array |
|
819 | + public static function readLines(string $filePath, int $amount = 0) : array |
|
820 | 820 | { |
821 | 821 | return self::getFileInfo($filePath) |
822 | 822 | ->getLineReader() |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | * |
867 | 867 | * @throws FileHelper_Exception |
868 | 868 | */ |
869 | - public static function createPathsReducer(array $paths=array()) : PathsReducer |
|
869 | + public static function createPathsReducer(array $paths = array()) : PathsReducer |
|
870 | 870 | { |
871 | 871 | return new PathsReducer($paths); |
872 | 872 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param int $tabSize The amount of spaces per tab. |
56 | 56 | * @return string |
57 | 57 | */ |
58 | - public static function tabs2spaces(string $string, int $tabSize=4) : string |
|
58 | + public static function tabs2spaces(string $string, int $tabSize = 4) : string |
|
59 | 59 | { |
60 | 60 | return ConvertHelper_String::tabs2spaces($string, $tabSize); |
61 | 61 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param int $tabSize The amount of spaces per tab in the source string. |
68 | 68 | * @return string |
69 | 69 | */ |
70 | - public static function spaces2tabs(string $string, int $tabSize=4) : string |
|
70 | + public static function spaces2tabs(string $string, int $tabSize = 4) : string |
|
71 | 71 | { |
72 | 72 | return ConvertHelper_String::spaces2tabs($string, $tabSize); |
73 | 73 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @deprecated Use the Highlighter class directly instead. |
141 | 141 | * @see Highlighter::xml() |
142 | 142 | */ |
143 | - public static function highlight_xml(string $xml, bool $formatSource=false) : string |
|
143 | + public static function highlight_xml(string $xml, bool $formatSource = false) : string |
|
144 | 144 | { |
145 | 145 | return Highlighter::xml($xml, $formatSource); |
146 | 146 | } |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | * @param bool $html |
207 | 207 | * @return string |
208 | 208 | */ |
209 | - public static function var_dump($var, bool $html=true) : string |
|
209 | + public static function var_dump($var, bool $html = true) : string |
|
210 | 210 | { |
211 | 211 | $info = parseVariable($var); |
212 | 212 | |
213 | - if($html) { |
|
213 | + if ($html) { |
|
214 | 214 | return $info->toHTML(); |
215 | 215 | } |
216 | 216 | |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | * @param bool $html Whether to style the dump as HTML. |
226 | 226 | * @return string |
227 | 227 | */ |
228 | - public static function print_r($var, bool $return=false, bool $html=true) : string |
|
228 | + public static function print_r($var, bool $return = false, bool $html = true) : string |
|
229 | 229 | { |
230 | 230 | $result = parseVariable($var)->enableType()->toString(); |
231 | 231 | |
232 | - if($html) |
|
232 | + if ($html) |
|
233 | 233 | { |
234 | 234 | $result = |
235 | 235 | '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'. |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | '</pre>'; |
238 | 238 | } |
239 | 239 | |
240 | - if(!$return) |
|
240 | + if (!$return) |
|
241 | 241 | { |
242 | 242 | echo $result; |
243 | 243 | } |
@@ -419,12 +419,12 @@ discard block |
||
419 | 419 | $output = ''; |
420 | 420 | $split = str_split($unicodeChar); |
421 | 421 | |
422 | - foreach($split as $octet) |
|
422 | + foreach ($split as $octet) |
|
423 | 423 | { |
424 | 424 | $ordInt = ord($octet); |
425 | 425 | // Convert from int (base 10) to hex (base 16), for PHP \x syntax |
426 | 426 | $ordHex = base_convert((string)$ordInt, 10, 16); |
427 | - $output .= '\x' . $ordHex; |
|
427 | + $output .= '\x'.$ordHex; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | return $output; |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | * |
639 | 639 | * @see JSHelper::buildRegexStatement() |
640 | 640 | */ |
641 | - public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) : string |
|
641 | + public static function regex2js(string $regex, string $statementType = JSHelper::JS_REGEX_OBJECT) : string |
|
642 | 642 | { |
643 | 643 | return JSHelper::buildRegexStatement($regex, $statementType); |
644 | 644 | } |
@@ -657,11 +657,11 @@ discard block |
||
657 | 657 | * @throws ConvertHelper_Exception |
658 | 658 | * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED |
659 | 659 | */ |
660 | - public static function var2json($variable, int $options=0, int $depth=512) : string |
|
660 | + public static function var2json($variable, int $options = 0, int $depth = 512) : string |
|
661 | 661 | { |
662 | 662 | $result = json_encode($variable, $options, $depth); |
663 | 663 | |
664 | - if($result !== false) { |
|
664 | + if ($result !== false) { |
|
665 | 665 | return $result; |
666 | 666 | } |
667 | 667 | |
@@ -701,12 +701,12 @@ discard block |
||
701 | 701 | { |
702 | 702 | $boms = FileHelper::createUnicodeHandling()->getUTFBOMs(); |
703 | 703 | |
704 | - foreach($boms as $bomChars) |
|
704 | + foreach ($boms as $bomChars) |
|
705 | 705 | { |
706 | 706 | $length = mb_strlen($bomChars); |
707 | 707 | $text = mb_substr($string, 0, $length); |
708 | 708 | |
709 | - if($text===$bomChars) |
|
709 | + if ($text === $bomChars) |
|
710 | 710 | { |
711 | 711 | return mb_substr($string, $length); |
712 | 712 | } |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE |
779 | 779 | * @see ConvertHelper_TextComparer::OPTION_PRECISION |
780 | 780 | */ |
781 | - public static function matchString(string $source, string $target, array $options=array()) : float |
|
781 | + public static function matchString(string $source, string $target, array $options = array()) : float |
|
782 | 782 | { |
783 | 783 | return (new ConvertHelper_TextComparer()) |
784 | 784 | ->setOptions($options) |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * @see ConvertHelper::INTERVAL_HOURS |
857 | 857 | * @see ConvertHelper::INTERVAL_DAYS |
858 | 858 | */ |
859 | - public static function interval2total(DateInterval $interval, string $unit=self::INTERVAL_SECONDS) : int |
|
859 | + public static function interval2total(DateInterval $interval, string $unit = self::INTERVAL_SECONDS) : int |
|
860 | 860 | { |
861 | 861 | return ConvertHelper_DateInterval::toTotal($interval, $unit); |
862 | 862 | } |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | * @param bool $short |
869 | 869 | * @return string|NULL |
870 | 870 | */ |
871 | - public static function date2dayName(DateTime $date, bool $short=false) : ?string |
|
871 | + public static function date2dayName(DateTime $date, bool $short = false) : ?string |
|
872 | 872 | { |
873 | 873 | return ConvertHelper_Date::toDayName($date, $short); |
874 | 874 | } |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | * @param bool $short |
889 | 889 | * @return string[] |
890 | 890 | */ |
891 | - public static function getDayNames(bool $short=false) : array |
|
891 | + public static function getDayNames(bool $short = false) : array |
|
892 | 892 | { |
893 | 893 | return ConvertHelper_Date::getDayNames($short); |
894 | 894 | } |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | * @param bool $caseInsensitive |
1048 | 1048 | * @return ConvertHelper_StringMatch[] |
1049 | 1049 | */ |
1050 | - public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array |
|
1050 | + public static function findString(string $needle, string $haystack, bool $caseInsensitive = false): array |
|
1051 | 1051 | { |
1052 | 1052 | return ConvertHelper_String::findString($needle, $haystack, $caseInsensitive); |
1053 | 1053 | } |
@@ -1097,17 +1097,17 @@ discard block |
||
1097 | 1097 | */ |
1098 | 1098 | public static function isInteger($value) : bool |
1099 | 1099 | { |
1100 | - if(is_int($value)) { |
|
1100 | + if (is_int($value)) { |
|
1101 | 1101 | return true; |
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | // booleans get converted to numbers, so they would |
1105 | 1105 | // actually match the regex. |
1106 | - if(is_bool($value)) { |
|
1106 | + if (is_bool($value)) { |
|
1107 | 1107 | return false; |
1108 | 1108 | } |
1109 | 1109 | |
1110 | - if(is_string($value) && $value !== '') { |
|
1110 | + if (is_string($value) && $value !== '') { |
|
1111 | 1111 | return preg_match('/\A-?\d+\z/', $value) === 1; |
1112 | 1112 | } |
1113 | 1113 | |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | * @param bool $keepKeys |
1174 | 1174 | * @return array<number|string,mixed> |
1175 | 1175 | */ |
1176 | - public static function arrayRemoveValues(array $sourceArray, array $values, bool $keepKeys=false) : array |
|
1176 | + public static function arrayRemoveValues(array $sourceArray, array $values, bool $keepKeys = false) : array |
|
1177 | 1177 | { |
1178 | 1178 | return ConvertHelper_Array::removeValues($sourceArray, $values, $keepKeys); |
1179 | 1179 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | { |
23 | 23 | $info = FileHelper::getFolderInfo($rootFolder); |
24 | 24 | |
25 | - if(!$info->exists()) |
|
25 | + if (!$info->exists()) |
|
26 | 26 | { |
27 | 27 | return true; |
28 | 28 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | foreach ($d as $item) |
33 | 33 | { |
34 | - if(self::processDeleteItem($item) === false) |
|
34 | + if (self::processDeleteItem($item) === false) |
|
35 | 35 | { |
36 | 36 | return false; |
37 | 37 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | { |
91 | 91 | $target = FileHelper::createFolder($target); |
92 | 92 | |
93 | - $d = $source->requireIsFolder()->getIterator(); |
|
93 | + $d = $source->requireIsFolder()->getIterator(); |
|
94 | 94 | |
95 | 95 | foreach ($d as $item) |
96 | 96 | { |
97 | - if($item->isDot()) |
|
97 | + if ($item->isDot()) |
|
98 | 98 | { |
99 | 99 | continue; |
100 | 100 | } |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | |
116 | 116 | if ($item->isFolder()) |
117 | 117 | { |
118 | - self::copy($item, $target . '/' . $item->getName()); |
|
118 | + self::copy($item, $target.'/'.$item->getName()); |
|
119 | 119 | } |
120 | - else if($item->isFile()) |
|
120 | + else if ($item->isFile()) |
|
121 | 121 | { |
122 | 122 | $item |
123 | 123 | ->requireIsFile() |
@@ -51,7 +51,7 @@ |
||
51 | 51 | $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size. |
52 | 52 | $result = (float)preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size. |
53 | 53 | |
54 | - if($unit) |
|
54 | + if ($unit) |
|
55 | 55 | { |
56 | 56 | // Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by. |
57 | 57 | return (int)round($result * (1024 ** stripos('bkmgtpezy', $unit[0]))); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | $pathString = AbstractPathInfo::type2string($path); |
44 | 44 | |
45 | - if(!isset(self::$infoCache[$pathString])) |
|
45 | + if (!isset(self::$infoCache[$pathString])) |
|
46 | 46 | { |
47 | 47 | self::$infoCache[$pathString] = new FileInfo($pathString); |
48 | 48 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | { |
73 | 73 | parent::__construct($path); |
74 | 74 | |
75 | - if(!self::is_file($this->path)) |
|
75 | + if (!self::is_file($this->path)) |
|
76 | 76 | { |
77 | 77 | throw new FileHelper_Exception( |
78 | 78 | 'Not a file path', |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | $path = trim($path); |
88 | 88 | |
89 | - if(empty($path)) |
|
89 | + if (empty($path)) |
|
90 | 90 | { |
91 | 91 | return false; |
92 | 92 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | return is_file($path) || pathinfo($path, PATHINFO_EXTENSION) !== ''; |
95 | 95 | } |
96 | 96 | |
97 | - public function removeExtension(bool $keepPath=false) : string |
|
97 | + public function removeExtension(bool $keepPath = false) : string |
|
98 | 98 | { |
99 | - if(!$keepPath) |
|
99 | + if (!$keepPath) |
|
100 | 100 | { |
101 | 101 | return pathinfo($this->getName(), PATHINFO_FILENAME); |
102 | 102 | } |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | return implode('/', $parts); |
111 | 111 | } |
112 | 112 | |
113 | - public function getExtension(bool $lowercase=true) : string |
|
113 | + public function getExtension(bool $lowercase = true) : string |
|
114 | 114 | { |
115 | 115 | $ext = pathinfo($this->path, PATHINFO_EXTENSION); |
116 | 116 | |
117 | - if($lowercase) |
|
117 | + if ($lowercase) |
|
118 | 118 | { |
119 | 119 | $ext = mb_strtolower($ext); |
120 | 120 | } |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function delete() : FileInfo |
132 | 132 | { |
133 | - if(!$this->exists()) |
|
133 | + if (!$this->exists()) |
|
134 | 134 | { |
135 | 135 | return $this; |
136 | 136 | } |
137 | 137 | |
138 | - if(unlink($this->path)) |
|
138 | + if (unlink($this->path)) |
|
139 | 139 | { |
140 | 140 | return $this; |
141 | 141 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | { |
163 | 163 | $this->checkCopyPrerequisites($targetPath); |
164 | 164 | |
165 | - if(copy($this->path, $targetPath)) |
|
165 | + if (copy($this->path, $targetPath)) |
|
166 | 166 | { |
167 | 167 | return self::factory($targetPath); |
168 | 168 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function getLineReader() : LineReader |
216 | 216 | { |
217 | - if(!isset($this->lineReader)) |
|
217 | + if (!isset($this->lineReader)) |
|
218 | 218 | { |
219 | 219 | $this->lineReader = new LineReader($this); |
220 | 220 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | $result = file_get_contents($this->getPath()); |
235 | 235 | |
236 | - if($result !== false) { |
|
236 | + if ($result !== false) { |
|
237 | 237 | return $result; |
238 | 238 | } |
239 | 239 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function putContents(string $content) : FileInfo |
257 | 257 | { |
258 | - if($this->exists()) |
|
258 | + if ($this->exists()) |
|
259 | 259 | { |
260 | 260 | $this->requireWritable(); |
261 | 261 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | ->requireWritable(); |
267 | 267 | } |
268 | 268 | |
269 | - if(file_put_contents($this->path, $content) !== false) |
|
269 | + if (file_put_contents($this->path, $content) !== false) |
|
270 | 270 | { |
271 | 271 | return $this; |
272 | 272 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param int $depth The folder depth to reduce the path to |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - public static function relativizeByDepth(string $path, int $depth=2) : string |
|
21 | + public static function relativizeByDepth(string $path, int $depth = 2) : string |
|
22 | 22 | { |
23 | 23 | $path = FileHelper::normalizePath($path); |
24 | 24 | |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | $tokens = array_filter($tokens); // remove empty entries (trailing slash for example) |
27 | 27 | $tokens = array_values($tokens); // re-index keys |
28 | 28 | |
29 | - if(empty($tokens)) { |
|
29 | + if (empty($tokens)) { |
|
30 | 30 | return ''; |
31 | 31 | } |
32 | 32 | |
33 | 33 | // remove the drive if present |
34 | - if(strpos($tokens[0], ':') !== false) { |
|
34 | + if (strpos($tokens[0], ':') !== false) { |
|
35 | 35 | array_shift($tokens); |
36 | 36 | } |
37 | 37 | |
38 | 38 | // path was only the drive |
39 | - if(count($tokens) === 0) { |
|
39 | + if (count($tokens) === 0) { |
|
40 | 40 | return ''; |
41 | 41 | } |
42 | 42 | |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | |
46 | 46 | // reduce the path to the specified depth |
47 | 47 | $length = count($tokens); |
48 | - if($length > $depth) { |
|
49 | - $tokens = array_slice($tokens, $length-$depth); |
|
48 | + if ($length > $depth) { |
|
49 | + $tokens = array_slice($tokens, $length - $depth); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | // append the last element again |