@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | { |
| 15 | 15 | $number = parseNumber($value, true); |
| 16 | 16 | |
| 17 | - if($number->getNumber() === $this->getNumber() && $number->hasUnits() === $this->hasUnits()) |
|
| 17 | + if ($number->getNumber() === $this->getNumber() && $number->hasUnits() === $this->hasUnits()) |
|
| 18 | 18 | { |
| 19 | 19 | return $this; |
| 20 | 20 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $number = parseNumber($number, true); |
| 32 | 32 | |
| 33 | - if($number->getNumber() === $this->getNumber() && $number->getUnits() === $this->getUnits()) |
|
| 33 | + if ($number->getNumber() === $this->getNumber() && $number->getUnits() === $this->getUnits()) |
|
| 34 | 34 | { |
| 35 | 35 | return $this; |
| 36 | 36 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $number = parseNumber($this, true); |
| 48 | 48 | $number->add($value); |
| 49 | 49 | |
| 50 | - if($number->getNumber() === $this->getNumber()) |
|
| 50 | + if ($number->getNumber() === $this->getNumber()) |
|
| 51 | 51 | { |
| 52 | 52 | return $this; |
| 53 | 53 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $number = parseNumber($this, true); |
| 65 | 65 | $number->subtract($value); |
| 66 | 66 | |
| 67 | - if($number->getNumber() === $this->getNumber()) |
|
| 67 | + if ($number->getNumber() === $this->getNumber()) |
|
| 68 | 68 | { |
| 69 | 69 | return $this; |
| 70 | 70 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $number = parseNumber($this, true); |
| 82 | 82 | $number->subtractPercent($percent); |
| 83 | 83 | |
| 84 | - if($number->getNumber() === $this->getNumber()) |
|
| 84 | + if ($number->getNumber() === $this->getNumber()) |
|
| 85 | 85 | { |
| 86 | 86 | return $this; |
| 87 | 87 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $number = parseNumber($this, true); |
| 99 | 99 | $number->addPercent($percent); |
| 100 | 100 | |
| 101 | - if($number->getNumber() === $this->getNumber()) |
|
| 101 | + if ($number->getNumber() === $this->getNumber()) |
|
| 102 | 102 | { |
| 103 | 103 | return $this; |
| 104 | 104 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $number = parseNumber($this, true); |
| 115 | 115 | $number->floorEven(); |
| 116 | 116 | |
| 117 | - if($number->getNumber() === $this->getNumber()) |
|
| 117 | + if ($number->getNumber() === $this->getNumber()) |
|
| 118 | 118 | { |
| 119 | 119 | return $this; |
| 120 | 120 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $number = parseNumber($this, true); |
| 131 | 131 | $number->ceilEven(); |
| 132 | 132 | |
| 133 | - if($number->getNumber() === $this->getNumber()) |
|
| 133 | + if ($number->getNumber() === $this->getNumber()) |
|
| 134 | 134 | { |
| 135 | 135 | return $this; |
| 136 | 136 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | protected function _setValue($value) |
| 132 | 132 | { |
| 133 | - if($value instanceof NumberInfo) { |
|
| 133 | + if ($value instanceof NumberInfo) { |
|
| 134 | 134 | $value = $value->getValue(); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function isPositive() : bool |
| 172 | 172 | { |
| 173 | - if($this->isEmpty()) |
|
| 173 | + if ($this->isEmpty()) |
|
| 174 | 174 | { |
| 175 | 175 | return false; |
| 176 | 176 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function isZero() : bool |
| 187 | 187 | { |
| 188 | - if($this->isEmpty()) |
|
| 188 | + if ($this->isEmpty()) |
|
| 189 | 189 | { |
| 190 | 190 | return false; |
| 191 | 191 | } |
@@ -231,23 +231,23 @@ discard block |
||
| 231 | 231 | { |
| 232 | 232 | // Append the units if the value is a number, |
| 233 | 233 | // so they can be inherited. |
| 234 | - if($this->hasUnits() && is_numeric($number)) |
|
| 234 | + if ($this->hasUnits() && is_numeric($number)) |
|
| 235 | 235 | { |
| 236 | 236 | $number .= $this->getUnits(); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | $new = parseNumber($number); |
| 240 | 240 | |
| 241 | - if($new->isEmpty()) |
|
| 241 | + if ($new->isEmpty()) |
|
| 242 | 242 | { |
| 243 | 243 | return $this; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if($new->getUnits() === $this->getUnits()) |
|
| 246 | + if ($new->getUnits() === $this->getUnits()) |
|
| 247 | 247 | { |
| 248 | 248 | $value = $new->getNumber(); |
| 249 | 249 | |
| 250 | - if($this->hasUnits()) { |
|
| 250 | + if ($this->hasUnits()) { |
|
| 251 | 251 | $value .= $this->getUnits(); |
| 252 | 252 | } |
| 253 | 253 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | { |
| 290 | 290 | $number = (float)$this->info['number']; |
| 291 | 291 | |
| 292 | - if($this->hasDecimals()) |
|
| 292 | + if ($this->hasDecimals()) |
|
| 293 | 293 | { |
| 294 | 294 | return $number; |
| 295 | 295 | } |
@@ -325,11 +325,11 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public function getUnits() : string |
| 327 | 327 | { |
| 328 | - if($this->isEmpty()) { |
|
| 328 | + if ($this->isEmpty()) { |
|
| 329 | 329 | return ''; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if(!$this->hasUnits()) { |
|
| 332 | + if (!$this->hasUnits()) { |
|
| 333 | 333 | return 'px'; |
| 334 | 334 | } |
| 335 | 335 | |
@@ -363,15 +363,15 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | public function toAttribute() : string |
| 365 | 365 | { |
| 366 | - if($this->isEmpty()) { |
|
| 366 | + if ($this->isEmpty()) { |
|
| 367 | 367 | return ''; |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - if($this->isZero()) { |
|
| 370 | + if ($this->isZero()) { |
|
| 371 | 371 | return '0'; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - if($this->isPercent()) { |
|
| 374 | + if ($this->isPercent()) { |
|
| 375 | 375 | return $this->getNumber().$this->getUnits(); |
| 376 | 376 | } |
| 377 | 377 | |
@@ -384,11 +384,11 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | public function toCSS() : string |
| 386 | 386 | { |
| 387 | - if($this->isEmpty()) { |
|
| 387 | + if ($this->isEmpty()) { |
|
| 388 | 388 | return ''; |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - if($this->isZero()) { |
|
| 391 | + if ($this->isZero()) { |
|
| 392 | 392 | return '0'; |
| 393 | 393 | } |
| 394 | 394 | |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | |
| 398 | 398 | public function __toString() |
| 399 | 399 | { |
| 400 | - if($this->isEmpty()) { |
|
| 400 | + if ($this->isEmpty()) { |
|
| 401 | 401 | return ''; |
| 402 | 402 | } |
| 403 | 403 | |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | */ |
| 504 | 504 | public function add($value) |
| 505 | 505 | { |
| 506 | - if($this->isEmpty()) |
|
| 506 | + if ($this->isEmpty()) |
|
| 507 | 507 | { |
| 508 | 508 | $this->setValue($value); |
| 509 | 509 | return $this; |
@@ -511,11 +511,11 @@ discard block |
||
| 511 | 511 | |
| 512 | 512 | $number = parseNumber($value); |
| 513 | 513 | |
| 514 | - if($number->getUnits() === $this->getUnits() || !$number->hasUnits()) |
|
| 514 | + if ($number->getUnits() === $this->getUnits() || !$number->hasUnits()) |
|
| 515 | 515 | { |
| 516 | 516 | $new = $this->getNumber() + $number->getNumber(); |
| 517 | 517 | |
| 518 | - if($this->hasUnits()) |
|
| 518 | + if ($this->hasUnits()) |
|
| 519 | 519 | { |
| 520 | 520 | $new .= $this->getUnits(); |
| 521 | 521 | } |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | */ |
| 537 | 537 | public function subtract($value) |
| 538 | 538 | { |
| 539 | - if($this->isEmpty()) |
|
| 539 | + if ($this->isEmpty()) |
|
| 540 | 540 | { |
| 541 | 541 | $this->setValue($value); |
| 542 | 542 | return $this; |
@@ -544,11 +544,11 @@ discard block |
||
| 544 | 544 | |
| 545 | 545 | $number = parseNumber($value); |
| 546 | 546 | |
| 547 | - if($number->getUnits() == $this->getUnits() || !$number->hasUnits()) |
|
| 547 | + if ($number->getUnits() == $this->getUnits() || !$number->hasUnits()) |
|
| 548 | 548 | { |
| 549 | 549 | $new = $this->getNumber() - $number->getNumber(); |
| 550 | 550 | |
| 551 | - if($this->hasUnits()) |
|
| 551 | + if ($this->hasUnits()) |
|
| 552 | 552 | { |
| 553 | 553 | $new .= $this->getUnits(); |
| 554 | 554 | } |
@@ -588,13 +588,13 @@ discard block |
||
| 588 | 588 | */ |
| 589 | 589 | protected function percentOperation(string $operation, $percent) |
| 590 | 590 | { |
| 591 | - if($this->isZeroOrEmpty()) { |
|
| 591 | + if ($this->isZeroOrEmpty()) { |
|
| 592 | 592 | return $this; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | $percent = parseNumber($percent); |
| 596 | 596 | |
| 597 | - if($percent->hasUnits() && !$percent->isPercent()) |
|
| 597 | + if ($percent->hasUnits() && !$percent->isPercent()) |
|
| 598 | 598 | { |
| 599 | 599 | return $this; |
| 600 | 600 | } |
@@ -602,18 +602,18 @@ discard block |
||
| 602 | 602 | $number = $this->getNumber(); |
| 603 | 603 | $value = $number * $percent->getNumber() / 100; |
| 604 | 604 | |
| 605 | - if($operation == '-') { |
|
| 605 | + if ($operation == '-') { |
|
| 606 | 606 | $number = $number - $value; |
| 607 | 607 | } else { |
| 608 | 608 | $number = $number + $value; |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - if($this->isUnitInteger()) |
|
| 611 | + if ($this->isUnitInteger()) |
|
| 612 | 612 | { |
| 613 | 613 | $number = intval($number); |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - if($this->hasUnits()) |
|
| 616 | + if ($this->hasUnits()) |
|
| 617 | 617 | { |
| 618 | 618 | $number .= $this->getUnits(); |
| 619 | 619 | } |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | { |
| 628 | 628 | $units = $this->getUnits(); |
| 629 | 629 | |
| 630 | - if(isset($this->knownUnits[$units])) |
|
| 630 | + if (isset($this->knownUnits[$units])) |
|
| 631 | 631 | { |
| 632 | 632 | return !$this->knownUnits[$units]; |
| 633 | 633 | } |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | { |
| 640 | 640 | $units = $this->getUnits(); |
| 641 | 641 | |
| 642 | - if(isset($this->knownUnits[$units])) |
|
| 642 | + if (isset($this->knownUnits[$units])) |
|
| 643 | 643 | { |
| 644 | 644 | return $this->knownUnits[$units]; |
| 645 | 645 | } |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | |
| 679 | 679 | $key = $this->createValueKey($value); |
| 680 | 680 | |
| 681 | - if(array_key_exists($key, $cache)) { |
|
| 681 | + if (array_key_exists($key, $cache)) { |
|
| 682 | 682 | return $cache[$key]; |
| 683 | 683 | } |
| 684 | 684 | |
@@ -688,13 +688,13 @@ discard block |
||
| 688 | 688 | 'number' => null |
| 689 | 689 | ); |
| 690 | 690 | |
| 691 | - if($key === '_EMPTY_') |
|
| 691 | + if ($key === '_EMPTY_') |
|
| 692 | 692 | { |
| 693 | 693 | $cache[$key]['empty'] = true; |
| 694 | 694 | return $cache[$key]; |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | - if($value === 0 || $value === '0') |
|
| 697 | + if ($value === 0 || $value === '0') |
|
| 698 | 698 | { |
| 699 | 699 | $cache[$key]['number'] = 0; |
| 700 | 700 | $cache[$key] = $this->filterInfo($cache[$key]); |
@@ -703,20 +703,20 @@ discard block |
||
| 703 | 703 | |
| 704 | 704 | $test = trim((string)$value); |
| 705 | 705 | |
| 706 | - if($test === '') |
|
| 706 | + if ($test === '') |
|
| 707 | 707 | { |
| 708 | 708 | $cache[$key]['empty'] = true; |
| 709 | 709 | return $cache[$key]; |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | // replace comma notation (which is only possible if it's a string) |
| 713 | - if(is_string($value)) |
|
| 713 | + if (is_string($value)) |
|
| 714 | 714 | { |
| 715 | 715 | $test = $this->preProcess($test, $cache, $value); |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | // convert to a number if it's numeric |
| 719 | - if(is_numeric($test)) |
|
| 719 | + if (is_numeric($test)) |
|
| 720 | 720 | { |
| 721 | 721 | $cache[$key]['number'] = (float)$test * 1; |
| 722 | 722 | $cache[$key] = $this->filterInfo($cache[$key]); |
@@ -742,19 +742,19 @@ discard block |
||
| 742 | 742 | $empty = false; |
| 743 | 743 | |
| 744 | 744 | $found = $this->findUnits($test); |
| 745 | - if($found !== null) |
|
| 745 | + if ($found !== null) |
|
| 746 | 746 | { |
| 747 | 747 | $number = $found['number']; |
| 748 | 748 | $units = $found['units']; |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | // the filters have to restore the value |
| 752 | - if($this->postProcess) |
|
| 752 | + if ($this->postProcess) |
|
| 753 | 753 | { |
| 754 | 754 | $number = $this->postProcess($number, $test); |
| 755 | 755 | } |
| 756 | 756 | // empty number |
| 757 | - else if($number === '' || $number === null || is_bool($number)) |
|
| 757 | + else if ($number === '' || $number === null || is_bool($number)) |
|
| 758 | 758 | { |
| 759 | 759 | $number = null; |
| 760 | 760 | $empty = true; |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | $number = trim($number); |
| 766 | 766 | |
| 767 | 767 | // may be an arbitrary string in some cases |
| 768 | - if(!is_numeric($number)) |
|
| 768 | + if (!is_numeric($number)) |
|
| 769 | 769 | { |
| 770 | 770 | $number = null; |
| 771 | 771 | $empty = true; |
@@ -797,17 +797,17 @@ discard block |
||
| 797 | 797 | $vlength = strlen($value); |
| 798 | 798 | $names = array_keys($this->knownUnits); |
| 799 | 799 | |
| 800 | - foreach($names as $unit) |
|
| 800 | + foreach ($names as $unit) |
|
| 801 | 801 | { |
| 802 | 802 | $ulength = strlen($unit); |
| 803 | - $start = $vlength-$ulength; |
|
| 804 | - if($start < 0) { |
|
| 803 | + $start = $vlength - $ulength; |
|
| 804 | + if ($start < 0) { |
|
| 805 | 805 | continue; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | $search = substr($value, $start, $ulength); |
| 809 | 809 | |
| 810 | - if($search==$unit) |
|
| 810 | + if ($search == $unit) |
|
| 811 | 811 | { |
| 812 | 812 | return array( |
| 813 | 813 | 'units' => $unit, |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | */ |
| 828 | 828 | private function createValueKey($value) : string |
| 829 | 829 | { |
| 830 | - if(!is_string($value) && !is_numeric($value)) |
|
| 830 | + if (!is_string($value) && !is_numeric($value)) |
|
| 831 | 831 | { |
| 832 | 832 | return '_EMPTY_'; |
| 833 | 833 | } |
@@ -891,12 +891,12 @@ discard block |
||
| 891 | 891 | protected function filterInfo(array $info) : array |
| 892 | 892 | { |
| 893 | 893 | $useUnits = 'px'; |
| 894 | - if($info['units'] !== null) { |
|
| 894 | + if ($info['units'] !== null) { |
|
| 895 | 895 | $useUnits = $info['units']; |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | 898 | // the units are non-decimal: convert decimal values |
| 899 | - if($this->knownUnits[$useUnits] === false && !$info['empty'] && is_numeric($info['number'])) |
|
| 899 | + if ($this->knownUnits[$useUnits] === false && !$info['empty'] && is_numeric($info['number'])) |
|
| 900 | 900 | { |
| 901 | 901 | $info['number'] = intval($info['number']); |
| 902 | 902 | } |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | { |
| 923 | 923 | $number = floor($this->getNumber()); |
| 924 | 924 | |
| 925 | - if($number % 2 == 1) $number--; |
|
| 925 | + if ($number % 2 == 1) $number--; |
|
| 926 | 926 | |
| 927 | 927 | return $this->setNumber($number); |
| 928 | 928 | } |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | { |
| 939 | 939 | $number = ceil($this->getNumber()); |
| 940 | 940 | |
| 941 | - if($number % 2 == 1) $number++; |
|
| 941 | + if ($number % 2 == 1) $number++; |
|
| 942 | 942 | |
| 943 | 943 | return $this->setNumber($number); |
| 944 | 944 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @see FileHelper_FileFinder |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -declare(strict_types = 1); |
|
| 10 | +declare(strict_types=1); |
|
| 11 | 11 | |
| 12 | 12 | namespace AppUtils; |
| 13 | 13 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $real = realpath($path); |
| 60 | 60 | |
| 61 | - if($real === false) |
|
| 61 | + if ($real === false) |
|
| 62 | 62 | { |
| 63 | 63 | throw new FileHelper_Exception( |
| 64 | 64 | 'Target path does not exist', |
@@ -305,22 +305,22 @@ discard block |
||
| 305 | 305 | return $this->getAll(); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - protected function find(string $path, bool $isRoot=false) : void |
|
| 308 | + protected function find(string $path, bool $isRoot = false) : void |
|
| 309 | 309 | { |
| 310 | - if($isRoot) { |
|
| 310 | + if ($isRoot) { |
|
| 311 | 311 | $this->found = array(); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | $recursive = $this->getBoolOption('recursive'); |
| 315 | 315 | |
| 316 | 316 | $d = new \DirectoryIterator($path); |
| 317 | - foreach($d as $item) |
|
| 317 | + foreach ($d as $item) |
|
| 318 | 318 | { |
| 319 | 319 | $pathname = $item->getPathname(); |
| 320 | 320 | |
| 321 | - if($item->isDir()) |
|
| 321 | + if ($item->isDir()) |
|
| 322 | 322 | { |
| 323 | - if($recursive && !$item->isDot()) { |
|
| 323 | + if ($recursive && !$item->isDot()) { |
|
| 324 | 324 | $this->find($pathname); |
| 325 | 325 | } |
| 326 | 326 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | |
| 330 | 330 | $file = $this->filterFile($pathname); |
| 331 | 331 | |
| 332 | - if($file !== null) |
|
| 332 | + if ($file !== null) |
|
| 333 | 333 | { |
| 334 | 334 | $this->found[] = $file; |
| 335 | 335 | } |
@@ -342,23 +342,23 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | $extension = FileHelper::getExtension($path); |
| 344 | 344 | |
| 345 | - if(!$this->filterExclusion($extension)) { |
|
| 345 | + if (!$this->filterExclusion($extension)) { |
|
| 346 | 346 | return null; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | $path = $this->filterPath($path); |
| 350 | 350 | |
| 351 | - if($this->getOption('strip-extensions') === true) |
|
| 351 | + if ($this->getOption('strip-extensions') === true) |
|
| 352 | 352 | { |
| 353 | 353 | $path = str_replace('.'.$extension, '', $path); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if($path === '') { |
|
| 356 | + if ($path === '') { |
|
| 357 | 357 | return null; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | $replace = $this->getOption('slash-replacement'); |
| 361 | - if(!empty($replace)) { |
|
| 361 | + if (!empty($replace)) { |
|
| 362 | 362 | $path = str_replace('/', $replace, $path); |
| 363 | 363 | } |
| 364 | 364 | |
@@ -377,15 +377,15 @@ discard block |
||
| 377 | 377 | $include = $this->getOption(self::OPTION_INCLUDE_EXTENSIONS); |
| 378 | 378 | $exclude = $this->getOption(self::OPTION_EXCLUDE_EXTENSIONS); |
| 379 | 379 | |
| 380 | - if(!empty($include)) |
|
| 380 | + if (!empty($include)) |
|
| 381 | 381 | { |
| 382 | - if(!in_array($extension, $include)) { |
|
| 382 | + if (!in_array($extension, $include)) { |
|
| 383 | 383 | return false; |
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | - else if(!empty($exclude)) |
|
| 386 | + else if (!empty($exclude)) |
|
| 387 | 387 | { |
| 388 | - if(in_array($extension, $exclude)) { |
|
| 388 | + if (in_array($extension, $exclude)) { |
|
| 389 | 389 | return false; |
| 390 | 390 | } |
| 391 | 391 | } |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | */ |
| 402 | 402 | protected function filterPath(string $path) : string |
| 403 | 403 | { |
| 404 | - switch($this->getStringOption(self::OPTION_PATHMODE)) |
|
| 404 | + switch ($this->getStringOption(self::OPTION_PATHMODE)) |
|
| 405 | 405 | { |
| 406 | 406 | case self::PATH_MODE_STRIP: |
| 407 | 407 | return basename($path); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | $name = $this->getName(); |
| 107 | 107 | |
| 108 | - if($this->info->hasNamespace()) { |
|
| 108 | + if ($this->info->hasNamespace()) { |
|
| 109 | 109 | $name = $this->info->getNamespace().'\\'.$this->name; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | $parts[] = 'class'; |
| 161 | 161 | $parts[] = $this->getName(); |
| 162 | 162 | |
| 163 | - if(!empty($this->extends)) { |
|
| 163 | + if (!empty($this->extends)) { |
|
| 164 | 164 | $parts[] = 'extends'; |
| 165 | 165 | $parts[] = $this->extends; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if(!empty($this->implements)) { |
|
| 168 | + if (!empty($this->implements)) { |
|
| 169 | 169 | $parts[] = 'implements'; |
| 170 | 170 | $parts[] = implode(', ', $this->implements); |
| 171 | 171 | } |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | protected function analyzeCode() : void |
| 186 | 186 | { |
| 187 | - if($this->keyword == 'abstract') { |
|
| 187 | + if ($this->keyword == 'abstract') { |
|
| 188 | 188 | $this->abstract = true; |
| 189 | - } else if($this->keyword == 'final') { |
|
| 189 | + } else if ($this->keyword == 'final') { |
|
| 190 | 190 | $this->final = true; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -203,16 +203,16 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | $tokenName = 'none'; |
| 205 | 205 | |
| 206 | - foreach($parts as $part) |
|
| 206 | + foreach ($parts as $part) |
|
| 207 | 207 | { |
| 208 | 208 | $part = str_replace(',', '', $part); |
| 209 | 209 | $part = trim($part); |
| 210 | - if(empty($part)) { |
|
| 210 | + if (empty($part)) { |
|
| 211 | 211 | continue; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | $name = strtolower($part); |
| 215 | - if($name == 'extends' || $name == 'implements') { |
|
| 215 | + if ($name == 'extends' || $name == 'implements') { |
|
| 216 | 216 | $tokenName = $name; |
| 217 | 217 | continue; |
| 218 | 218 | } |
@@ -222,13 +222,13 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | $this->implements = $tokens['implements']; |
| 224 | 224 | |
| 225 | - if(!empty($this->implements)) { |
|
| 225 | + if (!empty($this->implements)) { |
|
| 226 | 226 | usort($this->implements, function(string $a, string $b) { |
| 227 | 227 | return strnatcasecmp($a, $b); |
| 228 | 228 | }); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if(!empty($tokens['extends'])) { |
|
| 231 | + if (!empty($tokens['extends'])) { |
|
| 232 | 232 | $this->extends = $tokens['extends'][0]; |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -104,11 +104,11 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public static function fromClosure(Closure $closure, $origin) : NamedClosure |
| 106 | 106 | { |
| 107 | - if(is_object($origin)) |
|
| 107 | + if (is_object($origin)) |
|
| 108 | 108 | { |
| 109 | 109 | $description = get_class($origin); |
| 110 | 110 | } |
| 111 | - else if(is_array($origin)) |
|
| 111 | + else if (is_array($origin)) |
|
| 112 | 112 | { |
| 113 | 113 | $description = ConvertHelper::callback2string($origin); |
| 114 | 114 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param string|object $origin Optional origin. If not specified, the object and method name are used instead. |
| 127 | 127 | * @return NamedClosure |
| 128 | 128 | */ |
| 129 | - public static function fromObject(object $object, string $method, $origin='') : NamedClosure |
|
| 129 | + public static function fromObject(object $object, string $method, $origin = '') : NamedClosure |
|
| 130 | 130 | { |
| 131 | 131 | return self::fromArray(array($object, $method), $origin); |
| 132 | 132 | } |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | * @param string|object $origin |
| 137 | 137 | * @return NamedClosure |
| 138 | 138 | */ |
| 139 | - public static function fromArray(array $callback, $origin='') : NamedClosure |
|
| 139 | + public static function fromArray(array $callback, $origin = '') : NamedClosure |
|
| 140 | 140 | { |
| 141 | - if(empty($origin)) { |
|
| 141 | + if (empty($origin)) { |
|
| 142 | 142 | $origin = ConvertHelper::callback2string($callback); |
| 143 | - } else if(is_object($origin)) { |
|
| 143 | + } else if (is_object($origin)) { |
|
| 144 | 144 | $origin = get_class($origin); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @see RGBAColor::ERROR_INVALID_COLOR_COMPONENT |
| 72 | 72 | * @see RGBAColor::ERROR_INVALID_PERCENTAGE_VALUE |
| 73 | 73 | */ |
| 74 | - public function __construct(float $red, float $green, float $blue, float $alpha=100) |
|
| 74 | + public function __construct(float $red, float $green, float $blue, float $alpha = 100) |
|
| 75 | 75 | { |
| 76 | 76 | $this->setColorPercentage(self::COMPONENT_RED, $red); |
| 77 | 77 | $this->setColorPercentage(self:: COMPONENT_GREEN, $green); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function setTransparency(float $transparency) : RGBAColor |
| 164 | 164 | { |
| 165 | - return $this->setColorPercentage(self::COMPONENT_ALPHA, 100-$transparency); |
|
| 165 | + return $this->setColorPercentage(self::COMPONENT_ALPHA, 100 - $transparency); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | { |
| 283 | 283 | $this->requireValidComponent($name); |
| 284 | 284 | |
| 285 | - if($percentage >= 0 && $percentage <= 100) |
|
| 285 | + if ($percentage >= 0 && $percentage <= 100) |
|
| 286 | 286 | { |
| 287 | 287 | $this->color[$name] = $percentage; |
| 288 | 288 | return $this; |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | { |
| 313 | 313 | $this->requireValidComponent($name); |
| 314 | 314 | |
| 315 | - if($value >= 0 && $value <= 255) |
|
| 315 | + if ($value >= 0 && $value <= 255) |
|
| 316 | 316 | { |
| 317 | 317 | // Convert the value to a percentage for the internal storage. |
| 318 | 318 | $percentage = $value * 100 / 255; |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | private function requireValidComponent(string $name) : void |
| 339 | 339 | { |
| 340 | - if(in_array($name, self::COLOR_COMPONENTS)) |
|
| 340 | + if (in_array($name, self::COLOR_COMPONENTS)) |
|
| 341 | 341 | { |
| 342 | 342 | return; |
| 343 | 343 | } |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | { |
| 400 | 400 | $key = strval($offset); |
| 401 | 401 | |
| 402 | - if(isset($this->color[$key])) |
|
| 402 | + if (isset($this->color[$key])) |
|
| 403 | 403 | { |
| 404 | 404 | return $this->color[$key]; |
| 405 | 405 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | protected function __construct($subject) |
| 70 | 70 | { |
| 71 | - if(is_array($subject)) |
|
| 71 | + if (is_array($subject)) |
|
| 72 | 72 | { |
| 73 | 73 | $this->parseSerialized($subject); |
| 74 | 74 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function getPrevious() : ConvertHelper_ThrowableInfo |
| 128 | 128 | { |
| 129 | - if(isset($this->previous)) { |
|
| 129 | + if (isset($this->previous)) { |
|
| 130 | 130 | return $this->previous; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -151,18 +151,18 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | $string = 'Exception'; |
| 153 | 153 | |
| 154 | - if($this->hasCode()) { |
|
| 154 | + if ($this->hasCode()) { |
|
| 155 | 155 | $string .= ' #'.$this->code; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | $string .= ': '.$this->getMessage().PHP_EOL; |
| 159 | 159 | |
| 160 | - foreach($calls as $call) |
|
| 160 | + foreach ($calls as $call) |
|
| 161 | 161 | { |
| 162 | 162 | $string .= $call->toString().PHP_EOL; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if($this->hasPrevious()) |
|
| 165 | + if ($this->hasPrevious()) |
|
| 166 | 166 | { |
| 167 | 167 | $string .= PHP_EOL.PHP_EOL. |
| 168 | 168 | 'Previous error:'.PHP_EOL.PHP_EOL. |
@@ -253,11 +253,11 @@ discard block |
||
| 253 | 253 | 'previous' => null, |
| 254 | 254 | ); |
| 255 | 255 | |
| 256 | - if($this->hasPrevious()) { |
|
| 257 | - $result['previous'] = $this->previous->serialize(); |
|
| 256 | + if ($this->hasPrevious()) { |
|
| 257 | + $result['previous'] = $this->previous->serialize(); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - foreach($this->calls as $call) |
|
| 260 | + foreach ($this->calls as $call) |
|
| 261 | 261 | { |
| 262 | 262 | $result['calls'][] = $call->serialize(); |
| 263 | 263 | } |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | public function getFolderDepth() : int |
| 287 | 287 | { |
| 288 | 288 | $depth = $this->getOption('folder-depth'); |
| 289 | - if(!empty($depth)) { |
|
| 289 | + if (!empty($depth)) { |
|
| 290 | 290 | return $depth; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -340,12 +340,12 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | $this->setOptions($serialized['options']); |
| 342 | 342 | |
| 343 | - if(!empty($serialized['previous'])) |
|
| 343 | + if (!empty($serialized['previous'])) |
|
| 344 | 344 | { |
| 345 | 345 | $this->previous = ConvertHelper_ThrowableInfo::fromSerialized($serialized['previous']); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - foreach($serialized['calls'] as $def) |
|
| 348 | + foreach ($serialized['calls'] as $def) |
|
| 349 | 349 | { |
| 350 | 350 | $this->calls[] = ConvertHelper_ThrowableInfo_Call::fromSerialized($this, $def); |
| 351 | 351 | } |
@@ -357,16 +357,16 @@ discard block |
||
| 357 | 357 | $this->message = $e->getMessage(); |
| 358 | 358 | $this->code = $e->getCode(); |
| 359 | 359 | |
| 360 | - if(!isset($_REQUEST['REQUEST_URI'])) { |
|
| 360 | + if (!isset($_REQUEST['REQUEST_URI'])) { |
|
| 361 | 361 | $this->context = self::CONTEXT_COMMAND_LINE; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | $previous = $e->getPrevious(); |
| 365 | - if(!empty($previous)) { |
|
| 365 | + if (!empty($previous)) { |
|
| 366 | 366 | $this->previous = ConvertHelper::throwable2info($previous); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - if(isset($_SERVER['REQUEST_URI'])) { |
|
| 369 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 370 | 370 | $this->referer = $_SERVER['REQUEST_URI']; |
| 371 | 371 | } |
| 372 | 372 | |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | |
| 381 | 381 | $idx = 1; |
| 382 | 382 | |
| 383 | - foreach($trace as $entry) |
|
| 383 | + foreach ($trace as $entry) |
|
| 384 | 384 | { |
| 385 | 385 | $this->calls[] = ConvertHelper_ThrowableInfo_Call::fromTrace($this, $idx, $entry); |
| 386 | 386 | |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | * @return string |
| 416 | 416 | * @throws ConvertHelper_Exception |
| 417 | 417 | */ |
| 418 | - public function renderErrorMessage(bool $withDeveloperInfo=false) : string |
|
| 418 | + public function renderErrorMessage(bool $withDeveloperInfo = false) : string |
|
| 419 | 419 | { |
| 420 | 420 | $finalCall = $this->getFinalCall(); |
| 421 | 421 | |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | ->t('Message:') |
| 428 | 428 | ->add($this->getMessage()); |
| 429 | 429 | |
| 430 | - if($withDeveloperInfo) |
|
| 430 | + if ($withDeveloperInfo) |
|
| 431 | 431 | { |
| 432 | 432 | $message |
| 433 | 433 | ->eol() |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | ->add($finalCall->toString()); |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if($withDeveloperInfo && $this->hasDetails()) |
|
| 438 | + if ($withDeveloperInfo && $this->hasDetails()) |
|
| 439 | 439 | { |
| 440 | 440 | $message |
| 441 | 441 | ->t('Developer details:') |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | |
| 446 | 446 | $previous = $this->getPrevious(); |
| 447 | 447 | |
| 448 | - if($previous !== null) |
|
| 448 | + if ($previous !== null) |
|
| 449 | 449 | { |
| 450 | 450 | $message |
| 451 | 451 | ->eol() |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | |
| 461 | 461 | public function getDetails() : string |
| 462 | 462 | { |
| 463 | - if($this->exception instanceof BaseException) |
|
| 463 | + if ($this->exception instanceof BaseException) |
|
| 464 | 464 | { |
| 465 | 465 | return $this->exception->getDetails(); |
| 466 | 466 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param string $message Should not contain a date, just the system specific info. |
| 145 | 145 | * @return OperationResult |
| 146 | 146 | */ |
| 147 | - public function makeSuccess(string $message, int $code=0) : OperationResult |
|
| 147 | + public function makeSuccess(string $message, int $code = 0) : OperationResult |
|
| 148 | 148 | { |
| 149 | 149 | return $this->setMessage(self::TYPE_SUCCESS, $message, $code, true); |
| 150 | 150 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param string $message Should be as detailed as possible. |
| 156 | 156 | * @return OperationResult |
| 157 | 157 | */ |
| 158 | - public function makeError(string $message, int $code=0) : OperationResult |
|
| 158 | + public function makeError(string $message, int $code = 0) : OperationResult |
|
| 159 | 159 | { |
| 160 | 160 | return $this->setMessage(self::TYPE_ERROR, $message, $code, false); |
| 161 | 161 | } |
@@ -235,11 +235,11 @@ discard block |
||
| 235 | 235 | return $this->code; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - public function getMessage(string $type='') : string |
|
| 238 | + public function getMessage(string $type = '') : string |
|
| 239 | 239 | { |
| 240 | - if(!empty($type)) |
|
| 240 | + if (!empty($type)) |
|
| 241 | 241 | { |
| 242 | - if($this->type === $type) |
|
| 242 | + if ($this->type === $type) |
|
| 243 | 243 | { |
| 244 | 244 | return $this->message; |
| 245 | 245 | } |
@@ -263,11 +263,11 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @throws ConvertHelper_Exception |
| 265 | 265 | */ |
| 266 | - public function makeException(Throwable $e, int $code=0, bool $withDeveloperInfo=false) : OperationResult |
|
| 266 | + public function makeException(Throwable $e, int $code = 0, bool $withDeveloperInfo = false) : OperationResult |
|
| 267 | 267 | { |
| 268 | 268 | $info = parseThrowable($e); |
| 269 | 269 | |
| 270 | - if($code === 0) |
|
| 270 | + if ($code === 0) |
|
| 271 | 271 | { |
| 272 | 272 | $code = $info->getCode(); |
| 273 | 273 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public static function getPresetsManager() : RGBAColor_PresetsManager |
| 40 | 40 | { |
| 41 | - if(!isset(self::$presets)) |
|
| 41 | + if (!isset(self::$presets)) |
|
| 42 | 42 | { |
| 43 | 43 | self::$presets = new RGBAColor_PresetsManager(); |
| 44 | 44 | } |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public static function createAuto($subject) : RGBAColor |
| 62 | 62 | { |
| 63 | - if($subject instanceof RGBAColor) |
|
| 63 | + if ($subject instanceof RGBAColor) |
|
| 64 | 64 | { |
| 65 | 65 | return $subject; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if(is_array($subject)) |
|
| 68 | + if (is_array($subject)) |
|
| 69 | 69 | { |
| 70 | - if(RGBAColor_Converter::isColorArray($subject)) |
|
| 70 | + if (RGBAColor_Converter::isColorArray($subject)) |
|
| 71 | 71 | { |
| 72 | 72 | return self::createFromColor($subject); |
| 73 | 73 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | return self::createFromIndexedColor($subject); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if(is_string($subject)) |
|
| 78 | + if (is_string($subject)) |
|
| 79 | 79 | { |
| 80 | 80 | return self::createFromHEX($subject); |
| 81 | 81 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public static function createFromColor(array $color) : RGBAColor |
| 118 | 118 | { |
| 119 | - if(!isset($color[RGBAColor::COMPONENT_ALPHA])) |
|
| 119 | + if (!isset($color[RGBAColor::COMPONENT_ALPHA])) |
|
| 120 | 120 | { |
| 121 | 121 | $color[RGBAColor::COMPONENT_ALPHA] = 255; |
| 122 | 122 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $values = array_values($color); |
| 164 | 164 | $amountKeys = count($values); |
| 165 | 165 | |
| 166 | - if($amountKeys === 3) |
|
| 166 | + if ($amountKeys === 3) |
|
| 167 | 167 | { |
| 168 | 168 | return self::createFromColor(array( |
| 169 | 169 | RGBAColor::COMPONENT_RED => $color[0], |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | )); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if($amountKeys === 4) |
|
| 175 | + if ($amountKeys === 4) |
|
| 176 | 176 | { |
| 177 | 177 | return self::createFromColor(array( |
| 178 | 178 | RGBAColor::COMPONENT_RED => $color[0], |