@@ -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); |
@@ -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) |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | { |
317 | 317 | $info = self::getPathInfo($pathOrDirIterator); |
318 | 318 | |
319 | - if($extension === true || $info instanceof FolderInfo) |
|
319 | + if ($extension === true || $info instanceof FolderInfo) |
|
320 | 320 | { |
321 | 321 | return $info->getName(); |
322 | 322 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE |
338 | 338 | * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE |
339 | 339 | */ |
340 | - public static function parseJSONFile(string $file, string $targetEncoding='', $sourceEncoding=null) : array |
|
340 | + public static function parseJSONFile(string $file, string $targetEncoding = '', $sourceEncoding = null) : array |
|
341 | 341 | { |
342 | 342 | return JSONFile::factory(self::getFileInfo($file)) |
343 | 343 | ->setTargetEncoding($targetEncoding) |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * @throws FileHelper_Exception |
391 | 391 | * @see FileHelper::createFileFinder() |
392 | 392 | */ |
393 | - public static function findHTMLFiles(string $targetFolder, array $options=array()) : array |
|
393 | + public static function findHTMLFiles(string $targetFolder, array $options = array()) : array |
|
394 | 394 | { |
395 | 395 | return self::findFiles($targetFolder, array('html'), $options); |
396 | 396 | } |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @throws FileHelper_Exception |
410 | 410 | * @see FileHelper::createFileFinder() |
411 | 411 | */ |
412 | - public static function findPHPFiles(string $targetFolder, array $options=array()) : array |
|
412 | + public static function findPHPFiles(string $targetFolder, array $options = array()) : array |
|
413 | 413 | { |
414 | 414 | return self::findFiles($targetFolder, array('php'), $options); |
415 | 415 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * @see FileHelper::createFileFinder() |
432 | 432 | * @deprecated Use the file finder instead. |
433 | 433 | */ |
434 | - public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array |
|
434 | + public static function findFiles($targetFolder, array $extensions = array(), array $options = array()) : array |
|
435 | 435 | { |
436 | 436 | $finder = self::createFileFinder($targetFolder); |
437 | 437 | |
@@ -441,16 +441,16 @@ discard block |
||
441 | 441 | |
442 | 442 | $finder->setPathmodeStrip(); |
443 | 443 | |
444 | - if(isset($options['relative-path']) && $options['relative-path'] === true) |
|
444 | + if (isset($options['relative-path']) && $options['relative-path'] === true) |
|
445 | 445 | { |
446 | 446 | $finder->setPathmodeRelative(); |
447 | 447 | } |
448 | - else if(isset($options['absolute-path']) && $options['absolute-path'] === true) |
|
448 | + else if (isset($options['absolute-path']) && $options['absolute-path'] === true) |
|
449 | 449 | { |
450 | 450 | $finder->setPathmodeAbsolute(); |
451 | 451 | } |
452 | 452 | |
453 | - if(isset($options['strip-extension'])) |
|
453 | + if (isset($options['strip-extension'])) |
|
454 | 454 | { |
455 | 455 | $finder->stripExtensions(); |
456 | 456 | } |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | * @param bool $keepPath Whether to keep the path component, if any. Default PHP pathinfo behavior is not to. |
469 | 469 | * @return string |
470 | 470 | */ |
471 | - public static function removeExtension(string $filename, bool $keepPath=false) : string |
|
471 | + public static function removeExtension(string $filename, bool $keepPath = false) : string |
|
472 | 472 | { |
473 | 473 | return self::getFileInfo($filename)->removeExtension($keepPath); |
474 | 474 | } |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | |
481 | 481 | public static function createUnicodeHandling() : UnicodeHandling |
482 | 482 | { |
483 | - if(!isset(self::$unicodeHandling)) |
|
483 | + if (!isset(self::$unicodeHandling)) |
|
484 | 484 | { |
485 | 485 | self::$unicodeHandling = new UnicodeHandling(); |
486 | 486 | } |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
514 | 514 | * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
515 | 515 | */ |
516 | - public static function saveAsJSON($data, string $file, bool $pretty=false) : void |
|
516 | + public static function saveAsJSON($data, string $file, bool $pretty = false) : void |
|
517 | 517 | { |
518 | 518 | JSONFile::factory(self::getFileInfo($file)) |
519 | 519 | ->putData($data, $pretty); |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
532 | 532 | * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
533 | 533 | */ |
534 | - public static function saveFile(string $filePath, string $content='') : void |
|
534 | + public static function saveFile(string $filePath, string $content = '') : void |
|
535 | 535 | { |
536 | 536 | self::getFileInfo($filePath)->putContents($content); |
537 | 537 | } |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | */ |
575 | 575 | public static function checkPHPFileSyntax(string $path) |
576 | 576 | { |
577 | - if(!self::canMakePHPCalls()) { |
|
577 | + if (!self::canMakePHPCalls()) { |
|
578 | 578 | return true; |
579 | 579 | } |
580 | 580 | |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | // when the validation is successful, the first entry |
586 | 586 | // in the array contains the success message. When it |
587 | 587 | // is invalid, the first entry is always empty. |
588 | - if(!empty($output[0])) { |
|
588 | + if (!empty($output[0])) { |
|
589 | 589 | return true; |
590 | 590 | } |
591 | 591 | |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | public static function getModifiedDate(string $path) : ?DateTime |
607 | 607 | { |
608 | 608 | $time = filemtime($path); |
609 | - if($time === false) { |
|
609 | + if ($time === false) { |
|
610 | 610 | return null; |
611 | 611 | } |
612 | 612 | |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | * @param int $depth The folder depth to reduce the path to |
668 | 668 | * @return string |
669 | 669 | */ |
670 | - public static function relativizePathByDepth(string $path, int $depth=2) : string |
|
670 | + public static function relativizePathByDepth(string $path, int $depth = 2) : string |
|
671 | 671 | { |
672 | 672 | return PathRelativizer::relativizeByDepth($path, $depth); |
673 | 673 | } |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
707 | 707 | * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND |
708 | 708 | */ |
709 | - public static function requireFileExists($path, ?int $errorCode=null) : string |
|
709 | + public static function requireFileExists($path, ?int $errorCode = null) : string |
|
710 | 710 | { |
711 | 711 | return self::getPathInfo($path) |
712 | 712 | ->requireIsFile() |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | * @return string |
721 | 721 | * @throws FileHelper_Exception |
722 | 722 | */ |
723 | - public static function requireFileReadable(string $path, ?int $errorCode=null) : string |
|
723 | + public static function requireFileReadable(string $path, ?int $errorCode = null) : string |
|
724 | 724 | { |
725 | 725 | return self::getPathInfo($path) |
726 | 726 | ->requireIsFile() |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
810 | 810 | * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES |
811 | 811 | */ |
812 | - public static function readLines(string $filePath, int $amount=0) : array |
|
812 | + public static function readLines(string $filePath, int $amount = 0) : array |
|
813 | 813 | { |
814 | 814 | return self::getFileInfo($filePath) |
815 | 815 | ->getLineReader() |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | * |
860 | 860 | * @throws FileHelper_Exception |
861 | 861 | */ |
862 | - public static function createPathsReducer(array $paths=array()) : PathsReducer |
|
862 | + public static function createPathsReducer(array $paths = array()) : PathsReducer |
|
863 | 863 | { |
864 | 864 | return new PathsReducer($paths); |
865 | 865 | } |
@@ -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 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | interface PathInfoInterface |
25 | 25 | { |
26 | 26 | public function getName() : string; |
27 | - public function getExtension(bool $lowercase=true) : string; |
|
27 | + public function getExtension(bool $lowercase = true) : string; |
|
28 | 28 | public function getPath() : string; |
29 | 29 | public function exists() : bool; |
30 | 30 | public function isFolder() : bool; |
@@ -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() |