Skip to content

Commit

Permalink
🚨 Fix PHPStan findings
Browse files Browse the repository at this point in the history
  • Loading branch information
marcreichel committed Nov 7, 2021
1 parent e57c454 commit 7b6b8d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ parameters:
- '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist.#'
- '#Call to an undefined static method MarcReichel\\IGDBLaravel\\Models\\Game::foo\(\).#'
- '#Parameter \#1 \$string of function md5 expects string, mixed given.#'
- '#Cannot call method getUrl\(\) on mixed.#'
# - '#Unsafe usage of new static#'
excludePaths:
# - ./*/*/FileToBeExcluded.php
Expand Down
8 changes: 4 additions & 4 deletions src/Models/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function getUrl(string $size = 'thumb', bool $retina = false): string
{
$availableSizes = new ReflectionClass(Size::class);
$constants = collect($availableSizes->getConstants());
$sizeFromEnum = $constants->first(function($value) use ($size) {
$sizeFromEnum = $constants->first(function ($value) use ($size) {
return $value === $size;
});

Expand All @@ -24,12 +24,12 @@ public function getUrl(string $size = 'thumb', bool $retina = false): string
}

$basePath = static::IMAGE_BASE_PATH;
$id = $this->getAttribute('image_id');
$id = '' . $this->getAttribute('image_id');

if ($retina) {
$sizeFromEnum = Str::finish($sizeFromEnum, '_2x');
$size = Str::finish('' . $sizeFromEnum, '_2x');
}

return "$basePath/t_$sizeFromEnum/$id.jpg";
return "$basePath/t_$size/$id.jpg";
}
}

0 comments on commit 7b6b8d8

Please sign in to comment.