diff --git a/app/Jobs/CheckVersionUpdateJob.php b/app/Jobs/CheckVersionUpdateJob.php index 0794688..c2413c0 100644 --- a/app/Jobs/CheckVersionUpdateJob.php +++ b/app/Jobs/CheckVersionUpdateJob.php @@ -156,7 +156,7 @@ class CheckVersionUpdateJob private function extractLatestVersion(array $response, bool $enablePrereleases): array { - if (! $enablePrereleases || ! is_array($response) || ! isset($response[0])) { + if (! $enablePrereleases || ! isset($response[0])) { return [ Arr::get($response, 'tag_name'), $response, diff --git a/app/Models/DeviceModel.php b/app/Models/DeviceModel.php index fbc104f..7142829 100644 --- a/app/Models/DeviceModel.php +++ b/app/Models/DeviceModel.php @@ -87,24 +87,28 @@ final class DeviceModel extends Model */ protected function cssVariables(): Attribute { - return Attribute::get(function (mixed $value, array $attributes): array { - $vars = is_array($value) ? $value : (is_string($value) ? (json_decode($value, true) ?? []) : []); + /** @var Attribute, array> */ + return Attribute::get( + /** @return array */ + function (mixed $value, array $attributes): array { + $vars = is_array($value) ? $value : (is_string($value) ? (json_decode($value, true) ?? []) : []); - if (config('app.puppeteer_window_size_strategy') !== 'v2') { + if (config('app.puppeteer_window_size_strategy') !== 'v2') { + return $vars; + } + + $width = $attributes['width'] ?? null; + $height = $attributes['height'] ?? null; + + if (empty($vars['--screen-w']) && $width !== null && $width !== '') { + $vars['--screen-w'] = is_numeric($width) ? (int) $width.'px' : (string) $width; + } + if (empty($vars['--screen-h']) && $height !== null && $height !== '') { + $vars['--screen-h'] = is_numeric($height) ? (int) $height.'px' : (string) $height; + } + + /** @var array $vars */ return $vars; - } - - $width = $attributes['width'] ?? null; - $height = $attributes['height'] ?? null; - - if (empty($vars['--screen-w']) && $width !== null && $width !== '') { - $vars['--screen-w'] = is_numeric($width) ? (int) $width.'px' : (string) $width; - } - if (empty($vars['--screen-h']) && $height !== null && $height !== '') { - $vars['--screen-h'] = is_numeric($height) ? (int) $height.'px' : (string) $height; - } - - return $vars; - }); + }); } }