Passed
Push — master ( ba00c7...bfa3fc )
by Sebastian
08:42
created
src/PHP8Shims/CurlHandleShim.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 
7 7
 declare(strict_types=1);
8 8
 
9
-if(!class_exists('CurlHandle'))
9
+if (!class_exists('CurlHandle'))
10 10
 {
11 11
     /**
12 12
      * Shim to support PHPStan analysis on PHP7, while
Please login to merge, or discard this patch.
src/PHP8Shims/GDImageShim.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 
7 7
 declare(strict_types=1);
8 8
 
9
-if(!class_exists('GdImage'))
9
+if (!class_exists('GdImage'))
10 10
 {
11 11
     /**
12 12
      * Shim to support PHPStan analysis on PHP7, while
Please login to merge, or discard this patch.
src/FileHelper/PathInfoInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 interface PathInfoInterface extends Interface_Stringable
26 26
 {
27 27
     public function getName() : string;
28
-    public function getExtension(bool $lowercase=true) : string;
28
+    public function getExtension(bool $lowercase = true) : string;
29 29
     public function getPath() : string;
30 30
     public function getFolderPath() : string;
31 31
     public function exists() : bool;
Please login to merge, or discard this patch.
src/FileHelper/FileDownloader.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function setTimeout(int $timeout) : FileDownloader
43 43
     {
44
-        if($timeout > 0)
44
+        if ($timeout > 0)
45 45
         {
46 46
             $this->timeout = $timeout;
47 47
         }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @param bool $enabled
54 54
      * @return FileDownloader
55 55
      */
56
-    public function setSSLEnabled(bool $enabled=true) : FileDownloader
56
+    public function setSSLEnabled(bool $enabled = true) : FileDownloader
57 57
     {
58 58
         $this->SSLEnabled = $enabled;
59 59
         return $this;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 
75 75
         $output = curl_exec($ch);
76 76
 
77
-        if($output === false)
77
+        if ($output === false)
78 78
         {
79 79
             throw new FileHelper_Exception(
80 80
                 'Unable to open URL',
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         curl_close($ch);
91 91
 
92
-        if(is_string($output))
92
+        if (is_string($output))
93 93
         {
94 94
             return $output;
95 95
         }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
118 118
         curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
119 119
 
120
-        if(!$this->SSLEnabled)
120
+        if (!$this->SSLEnabled)
121 121
         {
122 122
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
123 123
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
Please login to merge, or discard this patch.
src/StyleCollection/StyleBuilder/ColorContainer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@  discard block
 block discarded – undo
11 11
 
12 12
 abstract class ColorContainer extends StyleContainer
13 13
 {
14
-    public function rgbaValues(int $red, int $green, int $blue, float $alpha=0) : StyleBuilder
14
+    public function rgbaValues(int $red, int $green, int $blue, float $alpha = 0) : StyleBuilder
15 15
     {
16 16
         return $this->rgba(ColorFactory::createCSS($red, $green, $blue, $alpha));
17 17
     }
18 18
 
19
-    public function rgba(RGBAColor $color, bool $important=false) : StyleBuilder
19
+    public function rgba(RGBAColor $color, bool $important = false) : StyleBuilder
20 20
     {
21 21
         return $this->setStyle($color->toCSS(), $important);
22 22
     }
23 23
 
24
-    public function hex(RGBAColor $color, bool $important=false) : StyleBuilder
24
+    public function hex(RGBAColor $color, bool $important = false) : StyleBuilder
25 25
     {
26 26
         return $this->setStyle('#'.$color->toHEX(), $important);
27 27
     }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * @return StyleBuilder
35 35
      * @throws ColorException
36 36
      */
37
-    public function hexString(string $hex, bool $important=false) : StyleBuilder
37
+    public function hexString(string $hex, bool $important = false) : StyleBuilder
38 38
     {
39 39
         return $this->hex(ColorFactory::createFromHEX($hex), $important);
40 40
     }
Please login to merge, or discard this patch.
src/ImageHelper.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
      *
121 121
      * @see ImageHelper::ERROR_GD_LIBRARY_NOT_INSTALLED
122 122
      */
123
-    public function __construct(?string $sourceFile=null, $resource=null, ?string $type=null)
123
+    public function __construct(?string $sourceFile = null, $resource = null, ?string $type = null)
124 124
     {
125 125
         // ensure that the GD library is installed
126
-        if(!function_exists('imagecreate')) 
126
+        if (!function_exists('imagecreate')) 
127 127
         {
128 128
             throw new ImageHelper_Exception(
129 129
                 'The PHP GD extension is not installed or not enabled.',
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             );
133 133
         }
134 134
         
135
-        if(is_resource($resource) || $resource instanceof GdImage)
135
+        if (is_resource($resource) || $resource instanceof GdImage)
136 136
         {
137 137
             $this->sourceImage = $resource;
138 138
             $this->type = $type;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             if ($type === null) {
157 157
                 throw new ImageHelper_Exception(
158 158
                     'Error opening image',
159
-                    'Not a valid supported image type for image ' . $this->file,
159
+                    'Not a valid supported image type for image '.$this->file,
160 160
                     self::ERROR_UNSUPPORTED_IMAGE_TYPE
161 161
                 );
162 162
             }
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
             $this->type = $type;
165 165
             $this->info = self::getImageSize($this->file);
166 166
 
167
-            if(!$this->isVector()) 
167
+            if (!$this->isVector()) 
168 168
             {
169
-                $method = 'imagecreatefrom' . $this->type;
169
+                $method = 'imagecreatefrom'.$this->type;
170 170
                 $this->sourceImage = $method($this->file);
171 171
                 if (!$this->sourceImage) {
172 172
                     throw new ImageHelper_Exception(
173 173
                         'Error creating new image',
174
-                        $method . ' failed',
174
+                        $method.' failed',
175 175
                         self::ERROR_FAILED_TO_CREATE_NEW_IMAGE
176 176
                     );
177 177
                 }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
         $this->width = $this->info->getWidth();
184 184
         $this->height = $this->info->getHeight();
185 185
 
186
-        if(!$this->isVector()) {
186
+        if (!$this->isVector()) {
187 187
             $this->setNewImage($this->duplicateImage($this->sourceImage));
188 188
         }
189 189
     }
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
     *
200 200
     * @see ImageHelper::ERROR_CANNOT_CREATE_IMAGE_OBJECT
201 201
     */
202
-    public static function createNew(int $width, int $height, string $type='png') : self
202
+    public static function createNew(int $width, int $height, string $type = 'png') : self
203 203
     {
204 204
         $img = imagecreatetruecolor($width, $height);
205
-        if($img !== false) {
205
+        if ($img !== false) {
206 206
             return self::createFromResource($img, $type);
207 207
         }
208 208
         
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      * @return ImageHelper
227 227
      * @throws ImageHelper_Exception
228 228
      */
229
-    public static function createFromResource($resource, ?string $type=null) : ImageHelper
229
+    public static function createFromResource($resource, ?string $type = null) : ImageHelper
230 230
     {
231 231
         self::requireResource($resource);
232 232
         
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
     */
263 263
     public static function setConfig(string $name, $value) : void
264 264
     {
265
-        if(isset(self::$config[$name])) {
265
+        if (isset(self::$config[$name])) {
266 266
             self::$config[$name] = $value;
267 267
         }
268 268
     }
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
     * @param bool $enabled
275 275
     * @return void
276 276
     */
277
-    public static function setAutoMemoryAdjustment(bool $enabled=true) : void
277
+    public static function setAutoMemoryAdjustment(bool $enabled = true) : void
278 278
     {
279 279
         self::setConfig('auto-memory-adjustment', $enabled);
280 280
     }
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
      */
315 315
     public function enableAlpha() : self
316 316
     {
317
-        if(!$this->alpha) 
317
+        if (!$this->alpha) 
318 318
         {
319 319
             self::addAlphaSupport($this->newImage, false);
320 320
             $this->alpha = true;
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
      * @param int|float $percent
355 355
      * @return $this
356 356
      */
357
-    public function sharpen($percent=0) : self
357
+    public function sharpen($percent = 0) : self
358 358
     {
359
-        if($percent <= 0) {
359
+        if ($percent <= 0) {
360 360
             return $this;
361 361
         }
362 362
         
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
      * @param int|float $percent
370 370
      * @return $this
371 371
      */
372
-    public function blur($percent=0) : self
372
+    public function blur($percent = 0) : self
373 373
     {
374
-        if($percent <= 0) {
374
+        if ($percent <= 0) {
375 375
             return $this;
376 376
         }
377 377
         
@@ -388,12 +388,12 @@  discard block
 block discarded – undo
388 388
     {
389 389
         // get a value that's equal to 64 - abs( factor )
390 390
         // ( using min/max to limit the factor to 0 - 64 to not get out of range values )
391
-        $val1Adjustment = 64 - min( 64, max( 0, abs( $factor ) ) );
391
+        $val1Adjustment = 64 - min(64, max(0, abs($factor)));
392 392
         
393 393
         // the base factor for the "current" pixel depends on if we are blurring or sharpening.
394 394
         // If we are blurring use 1, if sharpening use 9.
395 395
         $val1Base = 9;
396
-        if( abs( $factor ) !== $factor ) {
396
+        if (abs($factor) !== $factor) {
397 397
             $val1Base = 1;
398 398
         }
399 399
         
@@ -406,24 +406,24 @@  discard block
 block discarded – undo
406 406
         
407 407
         // the value for the surrounding pixels is either positive or negative depending on if we are blurring or sharpening.
408 408
         $val2 = -1;
409
-        if( abs( $factor ) !== $factor ) {
409
+        if (abs($factor) !== $factor) {
410 410
             $val2 = 1;
411 411
         }
412 412
         
413 413
         // setup matrix ..
414 414
         $matrix = array(
415
-            array( $val2, $val2, $val2 ),
416
-            array( $val2, $val1, $val2 ),
417
-            array( $val2, $val2, $val2 )
415
+            array($val2, $val2, $val2),
416
+            array($val2, $val1, $val2),
417
+            array($val2, $val2, $val2)
418 418
         );
419 419
         
420 420
         // calculate the correct divisor
421 421
         // actual divisor is equal to "$divisor = $val1 + $val2 * 8;"
422 422
         // but the following line is more generic
423
-        $divisor = array_sum( array_map( 'array_sum', $matrix ) );
423
+        $divisor = array_sum(array_map('array_sum', $matrix));
424 424
         
425 425
         // apply the matrix
426
-        imageconvolution( $this->newImage, $matrix, $divisor, 0 );
426
+        imageconvolution($this->newImage, $matrix, $divisor, 0);
427 427
         
428 428
         return $this;
429 429
     }
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
      */
553 553
     public function resample(?int $width = null, ?int $height = null) : ImageHelper
554 554
     {
555
-        if($this->isVector()) {
555
+        if ($this->isVector()) {
556 556
             return $this;
557 557
         }
558 558
         
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 
574 574
     public function resampleAndCrop(int $width, int $height) : ImageHelper
575 575
     {
576
-        if($this->isVector()) {
576
+        if ($this->isVector()) {
577 577
             return $this;
578 578
         }
579 579
 
@@ -619,14 +619,14 @@  discard block
 block discarded – undo
619 619
      * @param bool $fill Whether to fill the whole canvas with the transparency
620 620
      * @throws ImageHelper_Exception
621 621
      */
622
-    public static function addAlphaSupport($canvas, bool $fill=true) : void
622
+    public static function addAlphaSupport($canvas, bool $fill = true) : void
623 623
     {
624 624
         self::requireResource($canvas);
625 625
         
626
-        imagealphablending($canvas,true);
626
+        imagealphablending($canvas, true);
627 627
         imagesavealpha($canvas, true);
628 628
 
629
-        if($fill) {
629
+        if ($fill) {
630 630
             self::fillImageTransparent($canvas);
631 631
         }
632 632
     }
@@ -642,13 +642,13 @@  discard block
 block discarded – undo
642 642
      * @return $this
643 643
      * @throws ImageHelper_Exception
644 644
      */
645
-    public function save(string $targetFile, bool $dispose=true) : self
645
+    public function save(string $targetFile, bool $dispose = true) : self
646 646
     {
647
-        if($this->isVector()) {
647
+        if ($this->isVector()) {
648 648
             return $this;
649 649
         }
650 650
         
651
-        if(!is_resource($this->newImage)) {
651
+        if (!is_resource($this->newImage)) {
652 652
             throw new ImageHelper_Exception(
653 653
                 'Error creating new image',
654 654
                 'Cannot save an image, no valid image resource was created. You have to call one of the resample methods to create a new image.',
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
             unlink($targetFile);
661 661
         }
662 662
         
663
-        $method = 'image' . $this->type;
663
+        $method = 'image'.$this->type;
664 664
         if (!$method($this->newImage, $targetFile, $this->resolveQuality())) {
665 665
             throw new ImageHelper_Exception(
666 666
                 'Error creating new image',
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
             );
682 682
         }
683 683
 
684
-        if($dispose) {
684
+        if ($dispose) {
685 685
             $this->dispose();
686 686
         }
687 687
         
@@ -693,11 +693,11 @@  discard block
 block discarded – undo
693 693
      */
694 694
     public function dispose() : self
695 695
     {
696
-        if(is_resource($this->sourceImage)) {
696
+        if (is_resource($this->sourceImage)) {
697 697
             imagedestroy($this->sourceImage);
698 698
         }
699 699
         
700
-        if(is_resource($this->newImage)) {
700
+        if (is_resource($this->newImage)) {
701 701
             imagedestroy($this->newImage);
702 702
         }
703 703
 
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
     */
756 756
     protected function adjustMemory() : bool
757 757
     {
758
-        if(!self::$config['auto-memory-adjustment']) {
758
+        if (!self::$config['auto-memory-adjustment']) {
759 759
             return true;
760 760
         }
761 761
         
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
         if (function_exists('memory_get_usage') && memory_get_usage() + $memoryNeeded > $memoryLimit) {
785 785
             $newLimit = ($memoryLimit + (memory_get_usage() + $memoryNeeded)) / $MB;
786 786
             $newLimit = ceil($newLimit);
787
-            ini_set('memory_limit', $newLimit . 'M');
787
+            ini_set('memory_limit', $newLimit.'M');
788 788
 
789 789
             return true;
790 790
         }
@@ -816,16 +816,16 @@  discard block
 block discarded – undo
816 816
     */
817 817
     protected function resampleImage(int $newWidth, int $newHeight) : ImageHelper
818 818
     {
819
-        if($this->isVector()) {
819
+        if ($this->isVector()) {
820 820
             return $this;
821 821
         }
822 822
 
823
-        if($this->newWidth===$newWidth && $this->newHeight===$newHeight) {
823
+        if ($this->newWidth === $newWidth && $this->newHeight === $newHeight) {
824 824
             return $this;
825 825
         }
826 826
         
827
-        if($newWidth < 1) { $newWidth = 1; }
828
-        if($newHeight < 1) { $newHeight = 1; }
827
+        if ($newWidth < 1) { $newWidth = 1; }
828
+        if ($newHeight < 1) { $newHeight = 1; }
829 829
         
830 830
         $this->adjustMemory();
831 831
 
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
      */
857 857
     public static function getFileImageType($pathOrResource) : ?string
858 858
     {
859
-        if(!is_string($pathOrResource)) {
859
+        if (!is_string($pathOrResource)) {
860 860
             return 'png';
861 861
         }
862 862
 
@@ -896,15 +896,15 @@  discard block
 block discarded – undo
896 896
     * @see ImageHelper::ERROR_NOT_A_RESOURCE
897 897
     * @see ImageHelper::ERROR_INVALID_STREAM_IMAGE_TYPE
898 898
     */
899
-    public static function displayImageStream($resource, string $imageType, int $quality=-1) : void
899
+    public static function displayImageStream($resource, string $imageType, int $quality = -1) : void
900 900
     {
901 901
         self::requireResource($resource);
902 902
 
903 903
         $imageType = self::requireValidStreamType($imageType);
904 904
         
905
-        header('Content-type:image/' . $imageType);
905
+        header('Content-type:image/'.$imageType);
906 906
 
907
-        $function = 'image' . $imageType;
907
+        $function = 'image'.$imageType;
908 908
         
909 909
         $function($resource, null, $quality);
910 910
     }
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
     {
922 922
         $imageType = strtolower($imageType);
923 923
 
924
-        if(in_array($imageType, self::$streamTypes))
924
+        if (in_array($imageType, self::$streamTypes))
925 925
         {
926 926
             return $imageType;
927 927
         }
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
         if (headers_sent($file, $line)) {
949 949
             throw new ImageHelper_Exception(
950 950
                 'Error displaying image',
951
-                'Headers have already been sent: in file ' . $file . ':' . $line,
951
+                'Headers have already been sent: in file '.$file.':'.$line,
952 952
                 self::ERROR_HEADERS_ALREADY_SENT
953 953
             );
954 954
         }
@@ -965,16 +965,16 @@  discard block
 block discarded – undo
965 965
         }
966 966
 
967 967
         $format = self::getFileImageType($imageFile);
968
-        if($format === 'svg') {
968
+        if ($format === 'svg') {
969 969
             $format = 'svg+xml';
970 970
         }
971 971
 
972
-        $contentType = 'image/' . $format;
972
+        $contentType = 'image/'.$format;
973 973
         
974 974
         header('Content-Type: '.$contentType);
975
-        header("Last-Modified: " . gmdate("D, d M Y H:i:s", filemtime($imageFile)) . " GMT");
975
+        header("Last-Modified: ".gmdate("D, d M Y H:i:s", filemtime($imageFile))." GMT");
976 976
         header('Cache-Control: public');
977
-        header('Content-Length: ' . filesize($imageFile));
977
+        header('Content-Length: '.filesize($imageFile));
978 978
 
979 979
         readfile($imageFile);
980 980
     }
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
      * @see ImageHelper::ERROR_NOT_A_RESOURCE
1006 1006
      * @see ImageHelper::ERROR_CANNOT_CREATE_IMAGE_CANVAS
1007 1007
      */
1008
-    public function trim(?RGBAColor $color=null) : ImageHelper
1008
+    public function trim(?RGBAColor $color = null) : ImageHelper
1009 1009
     {
1010 1010
         return $this->trimImage($this->newImage, $color);
1011 1011
     }
@@ -1054,9 +1054,9 @@  discard block
 block discarded – undo
1054 1054
      *
1055 1055
      * @throws ImageHelper_Exception
1056 1056
      */
1057
-    protected function trimImage($img, ?RGBAColor $trimColor=null) : ImageHelper
1057
+    protected function trimImage($img, ?RGBAColor $trimColor = null) : ImageHelper
1058 1058
     {
1059
-        if($this->isVector()) {
1059
+        if ($this->isVector()) {
1060 1060
             return $this;
1061 1061
         }
1062 1062
 
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
         $trimmer = new ImageTrimmer($this, $img, $trimColor);
1066 1066
         $new = $trimmer->trim();
1067 1067
 
1068
-        if($new === null) {
1068
+        if ($new === null) {
1069 1069
             return $this;
1070 1070
         }
1071 1071
         
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
         
1093 1093
         $this->newImage = $image;
1094 1094
         $this->newWidth = imagesx($image);
1095
-        $this->newHeight= imagesy($image);
1095
+        $this->newHeight = imagesy($image);
1096 1096
 
1097 1097
         return $this;
1098 1098
     }
@@ -1107,11 +1107,11 @@  discard block
 block discarded – undo
1107 1107
     */
1108 1108
     public static function requireResource($subject) : void
1109 1109
     {
1110
-        if(is_resource($subject) && imagesx($subject)) {
1110
+        if (is_resource($subject) && imagesx($subject)) {
1111 1111
             return;
1112 1112
         }
1113 1113
 
1114
-        if($subject instanceof GdImage) {
1114
+        if ($subject instanceof GdImage) {
1115 1115
             return;
1116 1116
         }
1117 1117
         
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
     {
1138 1138
         $img = imagecreatetruecolor($width, $height);
1139 1139
         
1140
-        if($img === false) 
1140
+        if ($img === false) 
1141 1141
         {
1142 1142
             throw new ImageHelper_Exception(
1143 1143
                 'Error creating new image',
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
      * @param int $y
1157 1157
      * @return $this
1158 1158
      */
1159
-	public function fillWhite(int $x=0, int $y=0) : self
1159
+	public function fillWhite(int $x = 0, int $y = 0) : self
1160 1160
 	{
1161 1161
 	    $this->addRGBColor('white', 255, 255, 255);
1162 1162
         return $this->fill('white', $x, $y);
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
 	    self::requireResource($resource);
1186 1186
 	    
1187 1187
 	    $transparent = imagecolorallocatealpha($resource, 89, 14, 207, 127);
1188
-	    imagecolortransparent ($resource, $transparent);
1188
+	    imagecolortransparent($resource, $transparent);
1189 1189
 	    imagefill($resource, 0, 0, $transparent);
1190 1190
 	}
1191 1191
 
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
      * @param int $y
1196 1196
      * @return $this
1197 1197
      */
1198
-	public function fill(string $colorName, int $x=0, int $y=0) : self
1198
+	public function fill(string $colorName, int $x = 0, int $y = 0) : self
1199 1199
 	{
1200 1200
 	    imagefill($this->newImage, $x, $y, $this->colors[$colorName]);
1201 1201
 	    return $this;
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
      * @param int|float $angle
1224 1224
      * @return $this
1225 1225
      */
1226
-    public function textTTF(string $text, $size, string $colorName, int $x=0, int $y=0, $angle=0) : self
1226
+    public function textTTF(string $text, $size, string $colorName, int $x = 0, int $y = 0, $angle = 0) : self
1227 1227
     {
1228 1228
         imagealphablending($this->newImage, true);
1229 1229
         
@@ -1260,11 +1260,11 @@  discard block
 block discarded – undo
1260 1260
      * @return $this
1261 1261
      * @throws ImageHelper_Exception
1262 1262
      */
1263
-    public function paste(ImageHelper $target, int $xpos=0, int $ypos=0, int $sourceX=0, int $sourceY=0) : self
1263
+    public function paste(ImageHelper $target, int $xpos = 0, int $ypos = 0, int $sourceX = 0, int $sourceY = 0) : self
1264 1264
     {
1265 1265
         $img = $target->getImage();
1266 1266
         
1267
-        if($target->isAlpha()) {
1267
+        if ($target->isAlpha()) {
1268 1268
             $this->enableAlpha();
1269 1269
         }
1270 1270
         
@@ -1326,10 +1326,10 @@  discard block
 block discarded – undo
1326 1326
          */
1327 1327
         $sizes = array();
1328 1328
 
1329
-        for($i=1; $i<=1000; $i += 0.1) {
1329
+        for ($i = 1; $i <= 1000; $i += 0.1) {
1330 1330
             $size = $this->calcTextSize($text, $i);
1331 1331
             $sizes[] = $size;
1332
-            if($size->getWidth() >= $matchWidth) {
1332
+            if ($size->getWidth() >= $matchWidth) {
1333 1333
                 break;
1334 1334
             }
1335 1335
         }
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
         $diffLast = $last->getWidth() - $matchWidth;
1342 1342
         $diffPrev = $matchWidth - $prev->getWidth();
1343 1343
     
1344
-        if($diffLast <= $diffPrev) {
1344
+        if ($diffLast <= $diffPrev) {
1345 1345
             return $last;
1346 1346
         }
1347 1347
     
@@ -1370,14 +1370,14 @@  discard block
 block discarded – undo
1370 1370
             'bottom_left_y' => $box[1],
1371 1371
             'bottom_right_x' => $box[2],
1372 1372
             'bottom_right_y' => $box[3],
1373
-            'width' => $box[4]-$box[0],
1374
-            'height' => $box[1]-$box[7]
1373
+            'width' => $box[4] - $box[0],
1374
+            'height' => $box[1] - $box[7]
1375 1375
         ));
1376 1376
     }
1377 1377
     
1378 1378
     protected function requireTTFFont() : void
1379 1379
     {
1380
-        if(!empty($this->TTFFile)) {
1380
+        if (!empty($this->TTFFile)) {
1381 1381
             return;
1382 1382
         }
1383 1383
         
@@ -1406,7 +1406,7 @@  discard block
 block discarded – undo
1406 1406
      */
1407 1407
 	public static function getImageSize($pathOrResource) : ImageHelper_Size
1408 1408
 	{
1409
-	    if(is_resource($pathOrResource) || $pathOrResource instanceof GdImage)
1409
+	    if (is_resource($pathOrResource) || $pathOrResource instanceof GdImage)
1410 1410
 	    {
1411 1411
 	        return new ImageHelper_Size(array(
1412 1412
 	            'width' => imagesx($pathOrResource),
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
             'svg' => array(self::class, 'getImageSize_svg')
1423 1423
         );
1424 1424
 
1425
-	    if(isset($sizeMethods[$type]))
1425
+	    if (isset($sizeMethods[$type]))
1426 1426
 	    {
1427 1427
 	        return ClassHelper::requireObjectInstanceOf(
1428 1428
                 ImageHelper_Size::class,
@@ -1432,7 +1432,7 @@  discard block
 block discarded – undo
1432 1432
 
1433 1433
 	    $info = getimagesize($pathOrResource);
1434 1434
 
1435
-	    if($info !== false) {
1435
+	    if ($info !== false) {
1436 1436
 	        return new ImageHelper_Size($info);
1437 1437
 	    }
1438 1438
 	    
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
 	    $xml = XMLHelper::createSimplexml();
1460 1460
 	    $xml->loadFile($imagePath);
1461 1461
 	    
1462
-	    if($xml->hasErrors()) {
1462
+	    if ($xml->hasErrors()) {
1463 1463
 	        throw new ImageHelper_Exception(
1464 1464
 	            'Error opening SVG image',
1465 1465
 	            sprintf(
@@ -1474,7 +1474,7 @@  discard block
 block discarded – undo
1474 1474
 	    $xml->dispose();
1475 1475
 	    unset($xml);
1476 1476
 	    
1477
-	    if(!isset($data['@attributes']['viewBox'])) {
1477
+	    if (!isset($data['@attributes']['viewBox'])) {
1478 1478
 	        throw new ImageHelper_Exception(
1479 1479
 	            'SVG Image is corrupted',
1480 1480
 	            sprintf(
@@ -1491,7 +1491,7 @@  discard block
 block discarded – undo
1491 1491
 	    $viewBox = str_replace(' ', ',', $data['@attributes']['viewBox']);
1492 1492
 	    $size = explode(',', $viewBox);
1493 1493
 	    
1494
-	    if(count($size) !== 4)
1494
+	    if (count($size) !== 4)
1495 1495
 	    {
1496 1496
 	        throw new ImageHelper_Exception(
1497 1497
 	            'SVG image has an invalid viewBox attribute',
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
      * @return $this
1539 1539
      * @throws ImageHelper_Exception
1540 1540
      */
1541
-    public function crop(int $width, int $height, int $x=0, int $y=0) : ImageHelper
1541
+    public function crop(int $width, int $height, int $x = 0, int $y = 0) : ImageHelper
1542 1542
     {
1543 1543
         $new = $this->createNewImage($width, $height);
1544 1544
         
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
      */
1623 1623
     public function getColorAt(int $x, int $y) : RGBAColor
1624 1624
     {
1625
-        if($x > $this->getWidth() || $y > $this->getHeight()) 
1625
+        if ($x > $this->getWidth() || $y > $this->getHeight()) 
1626 1626
         {
1627 1627
             throw new ImageHelper_Exception(
1628 1628
                 'Position out of bounds',
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
     */
1665 1665
     public function getHash() : string
1666 1666
     {
1667
-        if($this->newImage === null)
1667
+        if ($this->newImage === null)
1668 1668
         {
1669 1669
             throw new ImageHelper_Exception(
1670 1670
                 'No image loaded to create a hash for.',
Please login to merge, or discard this patch.
src/ImageHelper/Size.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,27 +30,27 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function __construct(array $size)
32 32
     {
33
-        if(!isset($size['width'])) {
33
+        if (!isset($size['width'])) {
34 34
             $size['width'] = $size[0];
35 35
         }
36 36
         
37
-        if(!isset($size['height'])) {
37
+        if (!isset($size['height'])) {
38 38
             $size['height'] = $size[1];
39 39
         }
40 40
         
41
-        if(!isset($size[0])) {
41
+        if (!isset($size[0])) {
42 42
             $size[0] = $size['width'];
43 43
         }
44 44
         
45
-        if(!isset($size[1])) {
45
+        if (!isset($size[1])) {
46 46
             $size[1] = $size['height'];
47 47
         }
48 48
         
49
-        if(!isset($size['channels'])) {
49
+        if (!isset($size['channels'])) {
50 50
             $size['channels'] = 1;
51 51
         }
52 52
 
53
-        if(!isset($size['bits'])) {
53
+        if (!isset($size['bits'])) {
54 54
             $size['bits'] = -1;
55 55
         }
56 56
         
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public static function create($arrayOrInstance) : ImageHelper_Size
65 65
     {
66
-        if($arrayOrInstance instanceof self) {
66
+        if ($arrayOrInstance instanceof self) {
67 67
             return new self($arrayOrInstance->toArray());
68 68
         }
69 69
 
Please login to merge, or discard this patch.
src/FileHelper.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     public static function detectMimeType($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
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
252 252
      * @see FileHelper::ERROR_UNKNOWN_FILE_MIME_TYPE
253 253
      */
254
-    public static function sendFile($filePath, ?string $fileName = null, bool $asAttachment=true) : void
254
+    public static function sendFile($filePath, ?string $fileName = null, bool $asAttachment = true) : void
255 255
     {
256 256
         self::getFileInfo($filePath)->getDownloader()->send($fileName, $asAttachment);
257 257
     }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      * @throws FileHelper_Exception
269 269
      * @see FileHelper::ERROR_CANNOT_OPEN_URL
270 270
      */
271
-    public static function downloadFile(string $url, int $timeout=0, bool $SSLEnabled=false) : string
271
+    public static function downloadFile(string $url, int $timeout = 0, bool $SSLEnabled = false) : string
272 272
     {
273 273
         return FileDownloader::factory($url)
274 274
             ->setTimeout($timeout)
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     {
324 324
         $info = self::getPathInfo($pathOrDirIterator);
325 325
 
326
-        if($extension === true || $info instanceof FolderInfo)
326
+        if ($extension === true || $info instanceof FolderInfo)
327 327
         {
328 328
             return $info->getName();
329 329
         }
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
      * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE
346 346
      * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE
347 347
      */
348
-    public static function parseJSONFile($file, string $targetEncoding='', $sourceEncoding=null) : array
348
+    public static function parseJSONFile($file, string $targetEncoding = '', $sourceEncoding = null) : array
349 349
     {
350 350
         return JSONFile::factory($file)
351 351
             ->setTargetEncoding($targetEncoding)
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
      * @throws FileHelper_Exception
399 399
      * @see FileHelper::createFileFinder()
400 400
      */
401
-    public static function findHTMLFiles($targetFolder, array $options=array()) : array
401
+    public static function findHTMLFiles($targetFolder, array $options = array()) : array
402 402
     {
403 403
         return self::findFiles($targetFolder, array('html'), $options);
404 404
     }
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
      * @throws FileHelper_Exception
418 418
      * @see FileHelper::createFileFinder()
419 419
      */
420
-    public static function findPHPFiles($targetFolder, array $options=array()) : array
420
+    public static function findPHPFiles($targetFolder, array $options = array()) : array
421 421
     {
422 422
         return self::findFiles($targetFolder, array('php'), $options);
423 423
     }
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
     * @see FileHelper::createFileFinder()
440 440
     * @deprecated Use the file finder instead.
441 441
     */
442
-    public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array
442
+    public static function findFiles($targetFolder, array $extensions = array(), array $options = array()) : array
443 443
     {
444 444
         $finder = self::createFileFinder($targetFolder);
445 445
 
@@ -449,16 +449,16 @@  discard block
 block discarded – undo
449 449
 
450 450
         $finder->setPathmodeStrip();
451 451
         
452
-        if(isset($options['relative-path']) && $options['relative-path'] === true) 
452
+        if (isset($options['relative-path']) && $options['relative-path'] === true) 
453 453
         {
454 454
             $finder->setPathmodeRelative();
455 455
         } 
456
-        else if(isset($options['absolute-path']) && $options['absolute-path'] === true)
456
+        else if (isset($options['absolute-path']) && $options['absolute-path'] === true)
457 457
         {
458 458
             $finder->setPathmodeAbsolute();
459 459
         }
460 460
         
461
-        if(isset($options['strip-extension'])) 
461
+        if (isset($options['strip-extension'])) 
462 462
         {
463 463
             $finder->stripExtensions();
464 464
         }
@@ -477,16 +477,16 @@  discard block
 block discarded – undo
477 477
      * @return string
478 478
      * @throws FileHelper_Exception
479 479
      */
480
-    public static function removeExtension($filename, bool $keepPath=false) : string
480
+    public static function removeExtension($filename, bool $keepPath = false) : string
481 481
     {
482 482
         $path = self::getPathInfo($filename);
483 483
 
484
-        if($path instanceof FileInfo)
484
+        if ($path instanceof FileInfo)
485 485
         {
486 486
             return $path->removeExtension($keepPath);
487 487
         }
488 488
 
489
-        if($keepPath)
489
+        if ($keepPath)
490 490
         {
491 491
             return $filename;
492 492
         }
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 
502 502
     public static function createUnicodeHandling() : UnicodeHandling
503 503
     {
504
-        if(!isset(self::$unicodeHandling))
504
+        if (!isset(self::$unicodeHandling))
505 505
         {
506 506
             self::$unicodeHandling = new UnicodeHandling();
507 507
         }
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
      * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
536 536
      * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
537 537
      */
538
-    public static function saveAsJSON($data, $file, bool $pretty=false) : JSONFile
538
+    public static function saveAsJSON($data, $file, bool $pretty = false) : JSONFile
539 539
     {
540 540
         return JSONFile::factory($file)->putData($data, $pretty);
541 541
     }
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
      * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
554 554
      * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
555 555
      */
556
-    public static function saveFile($filePath, string $content='') : FileInfo
556
+    public static function saveFile($filePath, string $content = '') : FileInfo
557 557
     {
558 558
         return self::getFileInfo($filePath)->putContents($content);
559 559
     }
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
     * @param int $depth The folder depth to reduce the path to
666 666
     * @return string
667 667
     */
668
-    public static function relativizePathByDepth(string $path, int $depth=2) : string
668
+    public static function relativizePathByDepth(string $path, int $depth = 2) : string
669 669
     {
670 670
         return PathRelativizer::relativizeByDepth($path, $depth);
671 671
     }
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
705 705
     * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND
706 706
     */
707
-    public static function requireFileExists($path, ?int $errorCode=null) : string
707
+    public static function requireFileExists($path, ?int $errorCode = null) : string
708 708
     {
709 709
         return self::getPathInfo($path)
710 710
             ->requireIsFile()
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
      * @return string
719 719
      * @throws FileHelper_Exception
720 720
      */
721
-    public static function requireFileReadable($path, ?int $errorCode=null) : string
721
+    public static function requireFileReadable($path, ?int $errorCode = null) : string
722 722
     {
723 723
         return self::getPathInfo($path)
724 724
             ->requireIsFile()
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
797 797
      * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES
798 798
      */
799
-    public static function readLines($filePath, int $amount=0) : array
799
+    public static function readLines($filePath, int $amount = 0) : array
800 800
     {
801 801
         return self::getFileInfo($filePath)
802 802
             ->getLineReader()
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
      *
847 847
      * @throws FileHelper_Exception
848 848
      */
849
-    public static function createPathsReducer(array $paths=array()) : PathsReducer
849
+    public static function createPathsReducer(array $paths = array()) : PathsReducer
850 850
     {
851 851
         return new PathsReducer($paths);
852 852
     }
Please login to merge, or discard this patch.
src/FileHelper/AbstractPathInfo.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
         $path = realpath($this->path);
109 109
 
110
-        if($path !== false)
110
+        if ($path !== false)
111 111
         {
112 112
             return FileHelper::normalizePath($path);
113 113
         }
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
      * @return $this
127 127
      * @throws FileHelper_Exception
128 128
      */
129
-    private function requireTrue(bool $condition, string $conditionLabel, ?int $errorCode=null) : self
129
+    private function requireTrue(bool $condition, string $conditionLabel, ?int $errorCode = null) : self
130 130
     {
131
-        if($condition === true)
131
+        if ($condition === true)
132 132
         {
133 133
             return $this;
134 134
         }
135 135
 
136
-        if($errorCode === null)
136
+        if ($errorCode === null)
137 137
         {
138 138
             $errorCode = FileHelper::ERROR_FILE_DOES_NOT_EXIST;
139 139
         }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      * @return $this
151 151
      * @throws FileHelper_Exception
152 152
      */
153
-    public function requireExists(?int $errorCode=null) : self
153
+    public function requireExists(?int $errorCode = null) : self
154 154
     {
155 155
         return $this->requireTrue(
156 156
             !empty($this->path) && realpath($this->path) !== false,
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      * @return $this
165 165
      * @throws FileHelper_Exception
166 166
      */
167
-    public function requireReadable(?int $errorCode=null) : self
167
+    public function requireReadable(?int $errorCode = null) : self
168 168
     {
169 169
         $this->requireExists($errorCode);
170 170
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      * @return $this
181 181
      * @throws FileHelper_Exception
182 182
      */
183
-    public function requireWritable(?int $errorCode=null) : self
183
+    public function requireWritable(?int $errorCode = null) : self
184 184
     {
185 185
         return $this->requireTrue(
186 186
             $this->isWritable(),
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function requireIsFile() : FileInfo
199 199
     {
200
-        if($this instanceof FileInfo)
200
+        if ($this instanceof FileInfo)
201 201
         {
202 202
             return $this;
203 203
         }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
      */
221 221
     public function requireIsFolder() : FolderInfo
222 222
     {
223
-        if($this instanceof FolderInfo)
223
+        if ($this instanceof FolderInfo)
224 224
         {
225 225
             return $this;
226 226
         }
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
      */
242 242
     public static function type2string($path) : string
243 243
     {
244
-        if($path instanceof PathInfoInterface)
244
+        if ($path instanceof PathInfoInterface)
245 245
         {
246 246
             return $path->getPath();
247 247
         }
248 248
 
249
-        if($path instanceof SplFileInfo)
249
+        if ($path instanceof SplFileInfo)
250 250
         {
251 251
             return $path->getPathname();
252 252
         }
@@ -268,24 +268,24 @@  discard block
 block discarded – undo
268 268
      */
269 269
     public static function resolveType($path) : PathInfoInterface
270 270
     {
271
-        if($path instanceof PathInfoInterface)
271
+        if ($path instanceof PathInfoInterface)
272 272
         {
273 273
             return $path;
274 274
         }
275 275
 
276 276
         $path = self::type2string($path);
277 277
 
278
-        if(FolderInfo::is_dir($path))
278
+        if (FolderInfo::is_dir($path))
279 279
         {
280 280
             return FolderInfo::factory($path);
281 281
         }
282 282
 
283
-        if(FileInfo::is_file($path))
283
+        if (FileInfo::is_file($path))
284 284
         {
285 285
             return FileInfo::factory($path);
286 286
         }
287 287
 
288
-        if(!empty($path) && $path !== '.' && $path !== '..')
288
+        if (!empty($path) && $path !== '.' && $path !== '..')
289 289
         {
290 290
             return new IndeterminatePath($path);
291 291
         }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     public function getModifiedDate() : ?DateTime
341 341
     {
342 342
         $time = filemtime($this->getPath());
343
-        if($time === false) {
343
+        if ($time === false) {
344 344
             return null;
345 345
         }
346 346
 
Please login to merge, or discard this patch.