@@ -25,7 +25,7 @@ |
||
| 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; |
@@ -41,7 +41,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -11,17 +11,17 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -120,10 +120,10 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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.', |
@@ -30,27 +30,27 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param RGBAColor|null $trimColor |
| 38 | 38 | * @throws ImageHelper_Exception |
| 39 | 39 | */ |
| 40 | - public function __construct(ImageHelper $helper, $sourceImage, ?RGBAColor $trimColor=null) |
|
| 40 | + public function __construct(ImageHelper $helper, $sourceImage, ?RGBAColor $trimColor = null) |
|
| 41 | 41 | { |
| 42 | 42 | ImageHelper::requireResource($sourceImage); |
| 43 | 43 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | $targetColor = ColorFactory::createAuto($trimColor); |
| 52 | 52 | |
| 53 | - if($targetColor !== null) |
|
| 53 | + if ($targetColor !== null) |
|
| 54 | 54 | { |
| 55 | 55 | return $targetColor; |
| 56 | 56 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | ) |
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | - if($img !== false) { |
|
| 82 | + if ($img !== false) { |
|
| 83 | 83 | return $img; |
| 84 | 84 | } |
| 85 | 85 | |