@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @see \AppUtils\FileHelper\FileFinder |
8 | 8 | */ |
9 | 9 | |
10 | -declare(strict_types = 1); |
|
10 | +declare(strict_types=1); |
|
11 | 11 | |
12 | 12 | namespace AppUtils\FileHelper; |
13 | 13 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param bool $enabled |
91 | 91 | * @return FileFinder |
92 | 92 | */ |
93 | - public function makeRecursive(bool $enabled=true) : FileFinder |
|
93 | + public function makeRecursive(bool $enabled = true) : FileFinder |
|
94 | 94 | { |
95 | 95 | return $this->setOption('recursive', $enabled); |
96 | 96 | } |
@@ -295,22 +295,22 @@ discard block |
||
295 | 295 | return $this->getAll(); |
296 | 296 | } |
297 | 297 | |
298 | - protected function find(string $path, bool $isRoot=false) : void |
|
298 | + protected function find(string $path, bool $isRoot = false) : void |
|
299 | 299 | { |
300 | - if($isRoot) { |
|
300 | + if ($isRoot) { |
|
301 | 301 | $this->found = array(); |
302 | 302 | } |
303 | 303 | |
304 | 304 | $recursive = $this->getBoolOption('recursive'); |
305 | 305 | |
306 | 306 | $d = new DirectoryIterator($path); |
307 | - foreach($d as $item) |
|
307 | + foreach ($d as $item) |
|
308 | 308 | { |
309 | 309 | $pathname = $item->getPathname(); |
310 | 310 | |
311 | - if($item->isDir()) |
|
311 | + if ($item->isDir()) |
|
312 | 312 | { |
313 | - if($recursive && !$item->isDot()) { |
|
313 | + if ($recursive && !$item->isDot()) { |
|
314 | 314 | $this->find($pathname); |
315 | 315 | } |
316 | 316 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | |
320 | 320 | $file = $this->filterFile($pathname); |
321 | 321 | |
322 | - if($file !== null) |
|
322 | + if ($file !== null) |
|
323 | 323 | { |
324 | 324 | $this->found[] = $file; |
325 | 325 | } |
@@ -332,23 +332,23 @@ discard block |
||
332 | 332 | |
333 | 333 | $extension = FileHelper::getExtension($path); |
334 | 334 | |
335 | - if(!$this->filterExclusion($extension)) { |
|
335 | + if (!$this->filterExclusion($extension)) { |
|
336 | 336 | return null; |
337 | 337 | } |
338 | 338 | |
339 | 339 | $path = $this->filterPath($path); |
340 | 340 | |
341 | - if($this->getOption('strip-extensions') === true) |
|
341 | + if ($this->getOption('strip-extensions') === true) |
|
342 | 342 | { |
343 | 343 | $path = str_replace('.'.$extension, '', $path); |
344 | 344 | } |
345 | 345 | |
346 | - if($path === '') { |
|
346 | + if ($path === '') { |
|
347 | 347 | return null; |
348 | 348 | } |
349 | 349 | |
350 | 350 | $replace = $this->getOption('slash-replacement'); |
351 | - if(!empty($replace)) { |
|
351 | + if (!empty($replace)) { |
|
352 | 352 | $path = str_replace('/', $replace, $path); |
353 | 353 | } |
354 | 354 | |
@@ -367,13 +367,13 @@ discard block |
||
367 | 367 | $include = $this->getOption(self::OPTION_INCLUDE_EXTENSIONS); |
368 | 368 | $exclude = $this->getOption(self::OPTION_EXCLUDE_EXTENSIONS); |
369 | 369 | |
370 | - if(!empty($include)) |
|
370 | + if (!empty($include)) |
|
371 | 371 | { |
372 | - if(!in_array($extension, $include, true)) { |
|
372 | + if (!in_array($extension, $include, true)) { |
|
373 | 373 | return false; |
374 | 374 | } |
375 | 375 | } |
376 | - else if(!empty($exclude) && in_array($extension, $exclude, true)) |
|
376 | + else if (!empty($exclude) && in_array($extension, $exclude, true)) |
|
377 | 377 | { |
378 | 378 | return false; |
379 | 379 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | */ |
390 | 390 | protected function filterPath(string $path) : string |
391 | 391 | { |
392 | - switch($this->getStringOption(self::OPTION_PATHMODE)) |
|
392 | + switch ($this->getStringOption(self::OPTION_PATHMODE)) |
|
393 | 393 | { |
394 | 394 | case self::PATH_MODE_STRIP: |
395 | 395 | return basename($path); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @return $this |
125 | 125 | * @throws Request_Exception |
126 | 126 | */ |
127 | - public function setCallback(callable $callback, array $args=array()) : self |
|
127 | + public function setCallback(callable $callback, array $args = array()) : self |
|
128 | 128 | { |
129 | 129 | return $this->setValidation( |
130 | 130 | self::VALIDATION_TYPE_CALLBACK, |
@@ -149,22 +149,22 @@ discard block |
||
149 | 149 | // first off, apply filtering |
150 | 150 | $value = $this->filter($value); |
151 | 151 | |
152 | - if($this->valueType === self::VALUE_TYPE_LIST) |
|
152 | + if ($this->valueType === self::VALUE_TYPE_LIST) |
|
153 | 153 | { |
154 | - if(!is_array($value)) |
|
154 | + if (!is_array($value)) |
|
155 | 155 | { |
156 | 156 | $value = explode(',', $value); |
157 | 157 | } |
158 | 158 | |
159 | 159 | $keep = array(); |
160 | 160 | |
161 | - foreach($value as $subval) |
|
161 | + foreach ($value as $subval) |
|
162 | 162 | { |
163 | 163 | $subval = $this->filter($subval); |
164 | 164 | |
165 | 165 | $subval = $this->applyValidations($subval, true); |
166 | 166 | |
167 | - if($subval !== null) { |
|
167 | + if ($subval !== null) { |
|
168 | 168 | $keep[] = $subval; |
169 | 169 | } |
170 | 170 | } |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param mixed $value |
184 | 184 | * @return mixed |
185 | 185 | */ |
186 | - protected function applyValidations($value, bool $subval=false) |
|
186 | + protected function applyValidations($value, bool $subval = false) |
|
187 | 187 | { |
188 | 188 | // go through all enqueued validations in turn, each time |
189 | 189 | // replacing the value with the adjusted, validated value. |
190 | - foreach($this->validations as $validateDef) |
|
190 | + foreach ($this->validations as $validateDef) |
|
191 | 191 | { |
192 | 192 | $value = $this->validateType($value, $validateDef['type'], $validateDef['params'], $subval); |
193 | 193 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | { |
211 | 211 | $class = Request_Param_Validator::class.'_'.ucfirst($type); |
212 | 212 | |
213 | - if(!class_exists($class)) |
|
213 | + if (!class_exists($class)) |
|
214 | 214 | { |
215 | 215 | throw new Request_Exception( |
216 | 216 | 'Unknown validation type.', |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | { |
362 | 362 | $args = func_get_args(); // cannot be used as function parameter in some PHP versions |
363 | 363 | |
364 | - if(is_array($args[0])) |
|
364 | + if (is_array($args[0])) |
|
365 | 365 | { |
366 | 366 | $args = $args[0]; |
367 | 367 | } |
@@ -511,10 +511,10 @@ discard block |
||
511 | 511 | * @param mixed $default |
512 | 512 | * @return mixed |
513 | 513 | */ |
514 | - public function get($default=null) |
|
514 | + public function get($default = null) |
|
515 | 515 | { |
516 | 516 | $value = $this->request->getParam($this->paramName); |
517 | - if($value !== null && $value !== '') { |
|
517 | + if ($value !== null && $value !== '') { |
|
518 | 518 | return $value; |
519 | 519 | } |
520 | 520 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | { |
539 | 539 | foreach ($this->filters as $filter) |
540 | 540 | { |
541 | - $method = 'applyFilter_' . $filter['type']; |
|
541 | + $method = 'applyFilter_'.$filter['type']; |
|
542 | 542 | $value = $this->$method($value, $filter['params']); |
543 | 543 | } |
544 | 544 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | |
558 | 558 | $filter = new $class($this); |
559 | 559 | |
560 | - if($filter instanceof Request_Param_Filter) |
|
560 | + if ($filter instanceof Request_Param_Filter) |
|
561 | 561 | { |
562 | 562 | $filter->setOptions($config['params']); |
563 | 563 | return $filter->filter($value); |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | * @param bool $stripEmptyEntries Remove empty entries from the array? |
717 | 717 | * @return $this |
718 | 718 | */ |
719 | - public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : self |
|
719 | + public function addCommaSeparatedFilter(bool $trimEntries = true, bool $stripEmptyEntries = true) : self |
|
720 | 720 | { |
721 | 721 | $this->setArray(); |
722 | 722 | |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | * @return $this |
736 | 736 | * @throws Request_Exception |
737 | 737 | */ |
738 | - protected function addClassFilter(string $name, array $params=array()) : self |
|
738 | + protected function addClassFilter(string $name, array $params = array()) : self |
|
739 | 739 | { |
740 | 740 | return $this->addFilter( |
741 | 741 | self::FILTER_TYPE_CLASS, |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | public function isHeadersPosition($position) |
172 | 172 | { |
173 | - if($this->headersPosition === $position) { |
|
173 | + if ($this->headersPosition === $position) { |
|
174 | 174 | return true; |
175 | 175 | } |
176 | 176 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | self::HEADERS_TOP |
198 | 198 | ); |
199 | 199 | |
200 | - if(!in_array($position, $validPositions)) { |
|
200 | + if (!in_array($position, $validPositions)) { |
|
201 | 201 | throw new CSVHelper_Exception( |
202 | 202 | 'Invalid headers position', |
203 | 203 | sprintf( |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function getRow($index) |
255 | 255 | { |
256 | - if(isset($this->data[$index])) { |
|
256 | + if (isset($this->data[$index])) { |
|
257 | 257 | return $this->data[$index]; |
258 | 258 | } |
259 | 259 | |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | public function getColumn($index) |
321 | 321 | { |
322 | 322 | $data = array(); |
323 | - for($i=0; $i < $this->rowCount; $i++) { |
|
323 | + for ($i = 0; $i < $this->rowCount; $i++) { |
|
324 | 324 | $value = ''; |
325 | - if(isset($this->data[$i][$index])) { |
|
325 | + if (isset($this->data[$i][$index])) { |
|
326 | 326 | $value = $this->data[$i][$index]; |
327 | 327 | } |
328 | 328 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | public function columnExists($index) |
341 | 341 | { |
342 | - if($index < $this->columnCount) { |
|
342 | + if ($index < $this->columnCount) { |
|
343 | 343 | return true; |
344 | 344 | } |
345 | 345 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | { |
351 | 351 | $this->reset(); |
352 | 352 | |
353 | - if(empty(trim($this->csv))) { |
|
353 | + if (empty(trim($this->csv))) { |
|
354 | 354 | $this->addError('Tried to parse an empty CSV string.'); |
355 | 355 | return; |
356 | 356 | } |
@@ -362,14 +362,14 @@ discard block |
||
362 | 362 | |
363 | 363 | $parser = self::createParser(); |
364 | 364 | |
365 | - if(!$parser->parse($this->csv)) { |
|
365 | + if (!$parser->parse($this->csv)) { |
|
366 | 366 | $this->addError('The CSV string could not be parsed.'); |
367 | 367 | return; |
368 | 368 | } |
369 | 369 | |
370 | 370 | $result = $parser->data; |
371 | 371 | |
372 | - switch($this->headersPosition) |
|
372 | + switch ($this->headersPosition) |
|
373 | 373 | { |
374 | 374 | case self::HEADERS_TOP: |
375 | 375 | $this->headers = array_shift($result); |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | case self::HEADERS_LEFT: |
379 | 379 | $keep = array(); |
380 | 380 | $total = count($result); |
381 | - for($i=0; $i < $total; $i++) { |
|
381 | + for ($i = 0; $i < $total; $i++) { |
|
382 | 382 | $row = $result[$i]; |
383 | 383 | $this->headers[] = array_shift($row); |
384 | 384 | $keep[] = $row; |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | $this->data = $result; |
392 | 392 | $this->rowCount = count($this->data); |
393 | 393 | |
394 | - for($i=0; $i < $this->rowCount; $i++) { |
|
394 | + for ($i = 0; $i < $this->rowCount; $i++) { |
|
395 | 395 | $amount = count($this->data[$i]); |
396 | - if($amount > $this->columnCount) { |
|
396 | + if ($amount > $this->columnCount) { |
|
397 | 397 | $this->columnCount = $amount; |
398 | 398 | } |
399 | 399 | } |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | ',,' => ',' |
438 | 438 | ); |
439 | 439 | |
440 | - foreach($search as $char => $separator) { |
|
441 | - if(strstr($this->csv, $char)) { |
|
440 | + foreach ($search as $char => $separator) { |
|
441 | + if (strstr($this->csv, $char)) { |
|
442 | 442 | return $separator; |
443 | 443 | } |
444 | 444 | } |
@@ -452,11 +452,11 @@ discard block |
||
452 | 452 | * @param string $delimiter |
453 | 453 | * @return Csv |
454 | 454 | */ |
455 | - public static function createParser(string $delimiter=self::DELIMITER_AUTO) : Csv |
|
455 | + public static function createParser(string $delimiter = self::DELIMITER_AUTO) : Csv |
|
456 | 456 | { |
457 | 457 | $csv = new Csv(); |
458 | 458 | |
459 | - if($delimiter !== self::DELIMITER_AUTO) { |
|
459 | + if ($delimiter !== self::DELIMITER_AUTO) { |
|
460 | 460 | $csv->delimiter = $delimiter; |
461 | 461 | } |
462 | 462 | |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | |
485 | 485 | $result = $parser->auto($path); |
486 | 486 | |
487 | - if(is_string($result)) { |
|
487 | + if (is_string($result)) { |
|
488 | 488 | return $parser->data; |
489 | 489 | } |
490 | 490 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | $parser = self::createParser(); |
518 | 518 | $result = $parser->parse($string); |
519 | 519 | |
520 | - if($result === true) { |
|
520 | + if ($result === true) { |
|
521 | 521 | return $parser->data; |
522 | 522 | } |
523 | 523 |
@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | * @param int|NULL $code |
32 | 32 | * @param Throwable|NULL $previous |
33 | 33 | */ |
34 | - public function __construct(string $message, ?string $details=null, $code=null, $previous=null) |
|
34 | + public function __construct(string $message, ?string $details = null, $code = null, $previous = null) |
|
35 | 35 | { |
36 | - if(defined('APP_UTILS_TESTSUITE') && APP_UTILS_TESTSUITE === 'true') |
|
36 | + if (defined('APP_UTILS_TESTSUITE') && APP_UTILS_TESTSUITE === 'true') |
|
37 | 37 | { |
38 | 38 | $message .= PHP_EOL.$details; |
39 | 39 | } |
40 | 40 | |
41 | - if($code === null) |
|
41 | + if ($code === null) |
|
42 | 42 | { |
43 | 43 | $code = 0; |
44 | 44 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function display() : void |
64 | 64 | { |
65 | - if(!headers_sent()) { |
|
65 | + if (!headers_sent()) { |
|
66 | 66 | header('Content-type:text/plain; charset=utf-8'); |
67 | 67 | } |
68 | 68 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | throw new BaseException(''); |
91 | 91 | } |
92 | - catch(BaseException $e) |
|
92 | + catch (BaseException $e) |
|
93 | 93 | { |
94 | 94 | echo self::createInfo($e)->toString(); |
95 | 95 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | { |
105 | 105 | throw new BaseException(''); |
106 | 106 | } |
107 | - catch(BaseException $e) |
|
107 | + catch (BaseException $e) |
|
108 | 108 | { |
109 | 109 | echo '<pre style="background:#fff;font-family:monospace;font-size:14px;color:#444;padding:16px;border:solid 1px #999;border-radius:4px;">'; |
110 | 110 | echo self::createInfo($e)->toString(); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | { |
92 | 92 | $value = $_REQUEST[$name] ?? $default; |
93 | 93 | |
94 | - if(isset($this->knownParams[$name])) { |
|
94 | + if (isset($this->knownParams[$name])) { |
|
95 | 95 | $value = $this->knownParams[$name]->validate($value); |
96 | 96 | } |
97 | 97 | |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | * @param string $dispatcher Relative path to script to use for the URL. Append trailing slash if needed. |
189 | 189 | * @return string |
190 | 190 | */ |
191 | - public function buildURL(array $params = array(), string $dispatcher='') : string |
|
191 | + public function buildURL(array $params = array(), string $dispatcher = '') : string |
|
192 | 192 | { |
193 | - $url = rtrim($this->getBaseURL(), '/') . '/' . $dispatcher; |
|
193 | + $url = rtrim($this->getBaseURL(), '/').'/'.$dispatcher; |
|
194 | 194 | |
195 | 195 | // append any leftover parameters to the end of the URL |
196 | 196 | if (!empty($params)) { |
197 | - $url .= '?' . http_build_query($params, '', '&'); |
|
197 | + $url .= '?'.http_build_query($params, '', '&'); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | return $url; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function registerParam(string $name) : RequestParam |
227 | 227 | { |
228 | - if(!isset($this->knownParams[$name])) { |
|
228 | + if (!isset($this->knownParams[$name])) { |
|
229 | 229 | $param = new RequestParam($this, $name); |
230 | 230 | $this->knownParams[$name] = $param; |
231 | 231 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function getRegisteredParam(string $name) : RequestParam |
244 | 244 | { |
245 | - if(isset($this->knownParams[$name])) { |
|
245 | + if (isset($this->knownParams[$name])) { |
|
246 | 246 | return $this->knownParams[$name]; |
247 | 247 | } |
248 | 248 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | { |
303 | 303 | static $accept; |
304 | 304 | |
305 | - if(!isset($accept)) { |
|
305 | + if (!isset($accept)) { |
|
306 | 306 | $accept = new Request_AcceptHeaders(); |
307 | 307 | } |
308 | 308 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | { |
322 | 322 | $_REQUEST[$name] = $value; |
323 | 323 | |
324 | - if(isset($this->knownParams[$name])) { |
|
324 | + if (isset($this->knownParams[$name])) { |
|
325 | 325 | unset($this->knownParams[$name]); |
326 | 326 | } |
327 | 327 | |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | */ |
352 | 352 | public function removeParam(string $name) : Request |
353 | 353 | { |
354 | - if(isset($_REQUEST[$name])) { |
|
354 | + if (isset($_REQUEST[$name])) { |
|
355 | 355 | unset($_REQUEST[$name]); |
356 | 356 | } |
357 | 357 | |
358 | - if(isset($this->knownParams[$name])) { |
|
358 | + if (isset($this->knownParams[$name])) { |
|
359 | 359 | unset($this->knownParams[$name]); |
360 | 360 | } |
361 | 361 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function removeParams(array $names) : Request |
372 | 372 | { |
373 | - foreach($names as $name) { |
|
373 | + foreach ($names as $name) { |
|
374 | 374 | $this->removeParam($name); |
375 | 375 | } |
376 | 376 | |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | * @return bool |
389 | 389 | * @throws ConvertHelper_Exception |
390 | 390 | */ |
391 | - public function getBool(string $name, bool $default=false) : bool |
|
391 | + public function getBool(string $name, bool $default = false) : bool |
|
392 | 392 | { |
393 | 393 | $value = $this->getParam($name, $default); |
394 | 394 | |
395 | - if(ConvertHelper::isBoolean($value)) { |
|
395 | + if (ConvertHelper::isBoolean($value)) { |
|
396 | 396 | return ConvertHelper::string2bool($value); |
397 | 397 | } |
398 | 398 | |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | |
402 | 402 | public function validate() : void |
403 | 403 | { |
404 | - foreach($this->knownParams as $param) |
|
404 | + foreach ($this->knownParams as $param) |
|
405 | 405 | { |
406 | 406 | $name = $param->getName(); |
407 | 407 | |
408 | - if($param->isRequired() && !$this->hasParam($name)) |
|
408 | + if ($param->isRequired() && !$this->hasParam($name)) |
|
409 | 409 | { |
410 | 410 | throw new Request_Exception( |
411 | 411 | 'Missing request parameter '.$name, |
@@ -427,26 +427,26 @@ discard block |
||
427 | 427 | * @param mixed $default |
428 | 428 | * @return mixed |
429 | 429 | */ |
430 | - public function getFilteredParam(string $name, $default=null) |
|
430 | + public function getFilteredParam(string $name, $default = null) |
|
431 | 431 | { |
432 | 432 | $val = $this->getParam($name, $default); |
433 | 433 | |
434 | - if(is_string($val)) |
|
434 | + if (is_string($val)) |
|
435 | 435 | { |
436 | 436 | return htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8'); |
437 | 437 | } |
438 | 438 | |
439 | - if(is_bool($val)) |
|
439 | + if (is_bool($val)) |
|
440 | 440 | { |
441 | 441 | return ConvertHelper::boolStrict2string($val); |
442 | 442 | } |
443 | 443 | |
444 | - if(is_numeric($val)) |
|
444 | + if (is_numeric($val)) |
|
445 | 445 | { |
446 | 446 | return (string)$val; |
447 | 447 | } |
448 | 448 | |
449 | - if(is_null($val)) |
|
449 | + if (is_null($val)) |
|
450 | 450 | { |
451 | 451 | return ''; |
452 | 452 | } |
@@ -466,11 +466,11 @@ discard block |
||
466 | 466 | * @see Request::getJSONObject() |
467 | 467 | * @see Request::getJSONAssoc() |
468 | 468 | */ |
469 | - public function getJSON(string $name, bool $assoc=true) |
|
469 | + public function getJSON(string $name, bool $assoc = true) |
|
470 | 470 | { |
471 | 471 | $value = $this->getParam($name); |
472 | 472 | |
473 | - if(!empty($value) && is_string($value)) |
|
473 | + if (!empty($value) && is_string($value)) |
|
474 | 474 | { |
475 | 475 | try |
476 | 476 | { |
@@ -481,16 +481,16 @@ discard block |
||
481 | 481 | return array(); |
482 | 482 | } |
483 | 483 | |
484 | - if($assoc && is_array($data)) { |
|
484 | + if ($assoc && is_array($data)) { |
|
485 | 485 | return $data; |
486 | 486 | } |
487 | 487 | |
488 | - if(is_object($data)) { |
|
488 | + if (is_object($data)) { |
|
489 | 489 | return $data; |
490 | 490 | } |
491 | 491 | } |
492 | 492 | |
493 | - if($assoc) { |
|
493 | + if ($assoc) { |
|
494 | 494 | return array(); |
495 | 495 | } |
496 | 496 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | public function getJSONAssoc(string $name) : array |
508 | 508 | { |
509 | 509 | $result = $this->getJSON($name); |
510 | - if(is_array($result)) { |
|
510 | + if (is_array($result)) { |
|
511 | 511 | return $result; |
512 | 512 | } |
513 | 513 | |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | public function getJSONObject(string $name) : object |
525 | 525 | { |
526 | 526 | $result = $this->getJSON($name, false); |
527 | - if(is_object($result)) { |
|
527 | + if (is_object($result)) { |
|
528 | 528 | return $result; |
529 | 529 | } |
530 | 530 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | { |
542 | 542 | $payload = $data; |
543 | 543 | |
544 | - if(!is_string($payload)) { |
|
544 | + if (!is_string($payload)) { |
|
545 | 545 | $payload = json_encode($payload, JSON_THROW_ON_ERROR); |
546 | 546 | } |
547 | 547 | |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | * @param string[] $limitParams Whether to limit the comparison to these specific parameter names (if present) |
599 | 599 | * @return Request_URLComparer |
600 | 600 | */ |
601 | - public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer |
|
601 | + public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer |
|
602 | 602 | { |
603 | 603 | $comparer = new Request_URLComparer($this, $sourceURL, $targetURL); |
604 | 604 | $comparer->addLimitParams($limitParams); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function setAttributes(array $attributes) : AttributeCollection |
69 | 69 | { |
70 | - foreach($attributes as $name => $value) |
|
70 | + foreach ($attributes as $name => $value) |
|
71 | 71 | { |
72 | 72 | $this->attr($name, $value); |
73 | 73 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | return $this; |
76 | 76 | } |
77 | 77 | |
78 | - public function getAttribute(string $name, string $default='') : string |
|
78 | + public function getAttribute(string $name, string $default = '') : string |
|
79 | 79 | { |
80 | 80 | return $this->attributes[$name] ?? $default; |
81 | 81 | } |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | * @param array<string,string|number|bool|NULL|Interface_Stringable|StringBuilder_Interface> $attributes |
85 | 85 | * @return AttributeCollection |
86 | 86 | */ |
87 | - public static function create(array $attributes=array()) : AttributeCollection |
|
87 | + public static function create(array $attributes = array()) : AttributeCollection |
|
88 | 88 | { |
89 | 89 | return new AttributeCollection($attributes); |
90 | 90 | } |
91 | 91 | |
92 | - public function prop(string $name, bool $enabled=true) : AttributeCollection |
|
92 | + public function prop(string $name, bool $enabled = true) : AttributeCollection |
|
93 | 93 | { |
94 | - if($enabled) |
|
94 | + if ($enabled) |
|
95 | 95 | { |
96 | 96 | return $this->attr($name, $name); |
97 | 97 | } |
@@ -108,18 +108,18 @@ discard block |
||
108 | 108 | { |
109 | 109 | $string = Filtering::value2string($value); |
110 | 110 | |
111 | - if($name === 'class') |
|
111 | + if ($name === 'class') |
|
112 | 112 | { |
113 | 113 | return $this->addClasses(ConvertHelper::explodeTrim(' ', $string)); |
114 | 114 | } |
115 | 115 | |
116 | - if($name === 'style') |
|
116 | + if ($name === 'style') |
|
117 | 117 | { |
118 | 118 | $this->styles->parseStylesString($string); |
119 | 119 | return $this; |
120 | 120 | } |
121 | 121 | |
122 | - if($string !== '') |
|
122 | + if ($string !== '') |
|
123 | 123 | { |
124 | 124 | $this->attributes[$name] = $string; |
125 | 125 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | { |
139 | 139 | $this->attr($name, $value); |
140 | 140 | |
141 | - if(isset($this->attributes[$name])) |
|
141 | + if (isset($this->attributes[$name])) |
|
142 | 142 | { |
143 | 143 | $this->attributes[$name] = Filtering::quotes($this->attributes[$name]); |
144 | 144 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | public function remove(string $name) : AttributeCollection |
155 | 155 | { |
156 | - if(isset($this->attributes[$name])) |
|
156 | + if (isset($this->attributes[$name])) |
|
157 | 157 | { |
158 | 158 | unset($this->attributes[$name]); |
159 | 159 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | private function getRenderer() : AttributesRenderer |
177 | 177 | { |
178 | - if(isset($this->renderer)) |
|
178 | + if (isset($this->renderer)) |
|
179 | 179 | { |
180 | 180 | return $this->renderer; |
181 | 181 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | |
239 | 239 | public const TARGET_BLANK = '_blank'; |
240 | 240 | |
241 | - public function target(string $value=self::TARGET_BLANK) : AttributeCollection |
|
241 | + public function target(string $value = self::TARGET_BLANK) : AttributeCollection |
|
242 | 242 | { |
243 | 243 | return $this->attr('target', $value); |
244 | 244 | } |
@@ -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 | } |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | { |
101 | 101 | $target = FileHelper::createFolder($target); |
102 | 102 | |
103 | - $d = FileHelper::getPathInfo($source)->requireIsFolder()->getIterator(); |
|
103 | + $d = FileHelper::getPathInfo($source)->requireIsFolder()->getIterator(); |
|
104 | 104 | |
105 | 105 | foreach ($d as $item) |
106 | 106 | { |
107 | - if($item->isDot()) |
|
107 | + if ($item->isDot()) |
|
108 | 108 | { |
109 | 109 | continue; |
110 | 110 | } |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | |
126 | 126 | if ($item->isFolder()) |
127 | 127 | { |
128 | - self::copy($item, $target . '/' . $item->getName()); |
|
128 | + self::copy($item, $target.'/'.$item->getName()); |
|
129 | 129 | } |
130 | - else if($item->isFile()) |
|
130 | + else if ($item->isFile()) |
|
131 | 131 | { |
132 | 132 | $item |
133 | 133 | ->requireIsFile() |
@@ -29,22 +29,22 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function fromString($string) : bool |
31 | 31 | { |
32 | - if($string === '' || !is_scalar($string)) |
|
32 | + if ($string === '' || !is_scalar($string)) |
|
33 | 33 | { |
34 | 34 | return false; |
35 | 35 | } |
36 | 36 | |
37 | - if(is_bool($string)) |
|
37 | + if (is_bool($string)) |
|
38 | 38 | { |
39 | 39 | return $string; |
40 | 40 | } |
41 | 41 | |
42 | - if(is_string($string)) |
|
42 | + if (is_string($string)) |
|
43 | 43 | { |
44 | 44 | $string = strtolower($string); |
45 | 45 | } |
46 | 46 | |
47 | - if(array_key_exists($string, self::$booleanStrings)) |
|
47 | + if (array_key_exists($string, self::$booleanStrings)) |
|
48 | 48 | { |
49 | 49 | return self::$booleanStrings[$string]; |
50 | 50 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public static function toString($boolean, bool $yesno = false) : string |
75 | 75 | { |
76 | 76 | // allow 'yes', 'true', 'no', 'false' string notations as well |
77 | - if(!is_bool($boolean)) { |
|
77 | + if (!is_bool($boolean)) { |
|
78 | 78 | $boolean = self::fromString($boolean); |
79 | 79 | } |
80 | 80 | |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public static function isBoolean($value) : bool |
132 | 132 | { |
133 | - if(is_bool($value)) { |
|
133 | + if (is_bool($value)) { |
|
134 | 134 | return true; |
135 | 135 | } |
136 | 136 | |
137 | - if(!is_scalar($value)) { |
|
137 | + if (!is_scalar($value)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | public static function detectMimeType($fileName) : ?string |
209 | 209 | { |
210 | 210 | $ext = self::getExtension($fileName); |
211 | - if(empty($ext)) { |
|
211 | + if (empty($ext)) { |
|
212 | 212 | return null; |
213 | 213 | } |
214 | 214 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
253 | 253 | * @see FileHelper::ERROR_UNKNOWN_FILE_MIME_TYPE |
254 | 254 | */ |
255 | - public static function sendFile($filePath, ?string $fileName = null, bool $asAttachment=true) : void |
|
255 | + public static function sendFile($filePath, ?string $fileName = null, bool $asAttachment = true) : void |
|
256 | 256 | { |
257 | 257 | self::getFileInfo($filePath)->getDownloader()->send($fileName, $asAttachment); |
258 | 258 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @throws FileHelper_Exception |
270 | 270 | * @see FileHelper::ERROR_CANNOT_OPEN_URL |
271 | 271 | */ |
272 | - public static function downloadFile(string $url, int $timeout=0, bool $SSLEnabled=false) : string |
|
272 | + public static function downloadFile(string $url, int $timeout = 0, bool $SSLEnabled = false) : string |
|
273 | 273 | { |
274 | 274 | return FileDownloader::factory($url) |
275 | 275 | ->setTimeout($timeout) |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | { |
325 | 325 | $info = self::getPathInfo($pathOrDirIterator); |
326 | 326 | |
327 | - if($extension === true || $info instanceof FolderInfo) |
|
327 | + if ($extension === true || $info instanceof FolderInfo) |
|
328 | 328 | { |
329 | 329 | return $info->getName(); |
330 | 330 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE |
347 | 347 | * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE |
348 | 348 | */ |
349 | - public static function parseJSONFile($file, string $targetEncoding='', $sourceEncoding=null) : array |
|
349 | + public static function parseJSONFile($file, string $targetEncoding = '', $sourceEncoding = null) : array |
|
350 | 350 | { |
351 | 351 | return JSONFile::factory($file) |
352 | 352 | ->setTargetEncoding($targetEncoding) |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @throws FileHelper_Exception |
400 | 400 | * @see FileHelper::createFileFinder() |
401 | 401 | */ |
402 | - public static function findHTMLFiles($targetFolder, array $options=array()) : array |
|
402 | + public static function findHTMLFiles($targetFolder, array $options = array()) : array |
|
403 | 403 | { |
404 | 404 | return self::findFiles($targetFolder, array('html'), $options); |
405 | 405 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @throws FileHelper_Exception |
419 | 419 | * @see FileHelper::createFileFinder() |
420 | 420 | */ |
421 | - public static function findPHPFiles($targetFolder, array $options=array()) : array |
|
421 | + public static function findPHPFiles($targetFolder, array $options = array()) : array |
|
422 | 422 | { |
423 | 423 | return self::findFiles($targetFolder, array('php'), $options); |
424 | 424 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @see FileHelper::createFileFinder() |
441 | 441 | * @deprecated Use the file finder instead. |
442 | 442 | */ |
443 | - public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array |
|
443 | + public static function findFiles($targetFolder, array $extensions = array(), array $options = array()) : array |
|
444 | 444 | { |
445 | 445 | $finder = self::createFileFinder($targetFolder); |
446 | 446 | |
@@ -450,16 +450,16 @@ discard block |
||
450 | 450 | |
451 | 451 | $finder->setPathmodeStrip(); |
452 | 452 | |
453 | - if(isset($options['relative-path']) && $options['relative-path'] === true) |
|
453 | + if (isset($options['relative-path']) && $options['relative-path'] === true) |
|
454 | 454 | { |
455 | 455 | $finder->setPathmodeRelative(); |
456 | 456 | } |
457 | - else if(isset($options['absolute-path']) && $options['absolute-path'] === true) |
|
457 | + else if (isset($options['absolute-path']) && $options['absolute-path'] === true) |
|
458 | 458 | { |
459 | 459 | $finder->setPathmodeAbsolute(); |
460 | 460 | } |
461 | 461 | |
462 | - if(isset($options['strip-extension'])) |
|
462 | + if (isset($options['strip-extension'])) |
|
463 | 463 | { |
464 | 464 | $finder->stripExtensions(); |
465 | 465 | } |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * @return string |
479 | 479 | * @throws FileHelper_Exception |
480 | 480 | */ |
481 | - public static function removeExtension($filename, bool $keepPath=false) : string |
|
481 | + public static function removeExtension($filename, bool $keepPath = false) : string |
|
482 | 482 | { |
483 | 483 | return self::getFileInfo($filename)->removeExtension($keepPath); |
484 | 484 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | |
491 | 491 | public static function createUnicodeHandling() : UnicodeHandling |
492 | 492 | { |
493 | - if(!isset(self::$unicodeHandling)) |
|
493 | + if (!isset(self::$unicodeHandling)) |
|
494 | 494 | { |
495 | 495 | self::$unicodeHandling = new UnicodeHandling(); |
496 | 496 | } |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
525 | 525 | * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
526 | 526 | */ |
527 | - public static function saveAsJSON($data, $file, bool $pretty=false) : JSONFile |
|
527 | + public static function saveAsJSON($data, $file, bool $pretty = false) : JSONFile |
|
528 | 528 | { |
529 | 529 | return JSONFile::factory($file)->putData($data, $pretty); |
530 | 530 | } |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
543 | 543 | * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
544 | 544 | */ |
545 | - public static function saveFile($filePath, string $content='') : FileInfo |
|
545 | + public static function saveFile($filePath, string $content = '') : FileInfo |
|
546 | 546 | { |
547 | 547 | return self::getFileInfo($filePath)->putContents($content); |
548 | 548 | } |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | * @param int $depth The folder depth to reduce the path to |
655 | 655 | * @return string |
656 | 656 | */ |
657 | - public static function relativizePathByDepth(string $path, int $depth=2) : string |
|
657 | + public static function relativizePathByDepth(string $path, int $depth = 2) : string |
|
658 | 658 | { |
659 | 659 | return PathRelativizer::relativizeByDepth($path, $depth); |
660 | 660 | } |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
694 | 694 | * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND |
695 | 695 | */ |
696 | - public static function requireFileExists($path, ?int $errorCode=null) : string |
|
696 | + public static function requireFileExists($path, ?int $errorCode = null) : string |
|
697 | 697 | { |
698 | 698 | return self::getPathInfo($path) |
699 | 699 | ->requireIsFile() |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * @return string |
708 | 708 | * @throws FileHelper_Exception |
709 | 709 | */ |
710 | - public static function requireFileReadable($path, ?int $errorCode=null) : string |
|
710 | + public static function requireFileReadable($path, ?int $errorCode = null) : string |
|
711 | 711 | { |
712 | 712 | return self::getPathInfo($path) |
713 | 713 | ->requireIsFile() |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
786 | 786 | * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES |
787 | 787 | */ |
788 | - public static function readLines($filePath, int $amount=0) : array |
|
788 | + public static function readLines($filePath, int $amount = 0) : array |
|
789 | 789 | { |
790 | 790 | return self::getFileInfo($filePath) |
791 | 791 | ->getLineReader() |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * |
836 | 836 | * @throws FileHelper_Exception |
837 | 837 | */ |
838 | - public static function createPathsReducer(array $paths=array()) : PathsReducer |
|
838 | + public static function createPathsReducer(array $paths = array()) : PathsReducer |
|
839 | 839 | { |
840 | 840 | return new PathsReducer($paths); |
841 | 841 | } |