From d4f0d09c44700c78d1718cd40da404b1c800b935 Mon Sep 17 00:00:00 2001 From: timvandijck Date: Fri, 3 May 2024 14:05:33 +0000 Subject: [PATCH] Fix styling --- src/Image.php | 6 ++++-- src/OptimizerChain.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Image.php b/src/Image.php index f7def19..a1029cd 100644 --- a/src/Image.php +++ b/src/Image.php @@ -10,13 +10,14 @@ class Image protected const ALLOWED_PROTOCOLS = ['file']; protected const WINDOWS_LOCAL_FILENAME_REGEX = '/^[a-z]:(?:[\\\\\/]?(?:[\w\s!#()-]+|[\.]{1,2})+)*[\\\\\/]?/i'; + public function __construct(string $pathToImage) { - if (!$this->isProtocolAllowed($pathToImage)) { + if (! $this->isProtocolAllowed($pathToImage)) { throw new InvalidArgumentException(\sprintf('The output file scheme is not supported. Expected one of [\'%s\'].', \implode('\', \'', self::ALLOWED_PROTOCOLS))); } - if (!file_exists($pathToImage)) { + if (! file_exists($pathToImage)) { throw new InvalidArgumentException("`{$pathToImage}` does not exist"); } @@ -39,6 +40,7 @@ public function extension(): string return strtolower($extension); } + protected function isProtocolAllowed($filename) { if (false === $parsedFilename = \parse_url($filename)) { diff --git a/src/OptimizerChain.php b/src/OptimizerChain.php index 7bf4018..59421aa 100644 --- a/src/OptimizerChain.php +++ b/src/OptimizerChain.php @@ -65,7 +65,7 @@ public function optimize(string $pathToImage, string $pathToOutput = null) { if ($pathToOutput) { $check = copy($pathToImage, $pathToOutput); - if($check == false){ + if($check == false) { throw new InvalidArgumentException("Cannot copy file"); } $pathToImage = $pathToOutput;