Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
timvandijck authored and github-actions[bot] committed May 3, 2024
1 parent 89847b5 commit d4f0d09
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand All @@ -39,6 +40,7 @@ public function extension(): string

return strtolower($extension);
}

protected function isProtocolAllowed($filename)
{
if (false === $parsedFilename = \parse_url($filename)) {
Expand Down
2 changes: 1 addition & 1 deletion src/OptimizerChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d4f0d09

Please sign in to comment.