chore: add larastan

This commit is contained in:
Benjamin Nussbaum 2025-06-17 22:18:20 +02:00
parent c1a4acc40a
commit 1122764333
8 changed files with 209 additions and 4 deletions

View file

@ -98,6 +98,7 @@ class MashupCreateCommand extends Command
protected function selectPlaylist(Device $device): ?Playlist
{
/** @var Collection|Playlist[] $playlists */
$playlists = $device->playlists;
if ($playlists->isEmpty()) {
$this->error('No playlists found for this device. Please create a playlist first.');
@ -107,7 +108,7 @@ class MashupCreateCommand extends Command
$playlistId = select(
label: 'Select a playlist',
options: $playlists->mapWithKeys(fn ($playlist) => [$playlist->id => $playlist->name])->toArray()
options: $playlists->mapWithKeys(fn (Playlist $playlist) => [$playlist->id => $playlist->name])->toArray()
);
return $playlists->firstWhere('id', $playlistId);

View file

@ -142,6 +142,7 @@ class Device extends Model
public function getNextPlaylistItem(): ?PlaylistItem
{
// Get all active playlists
/** @var \Illuminate\Support\Collection|Playlist[] $playlists */
$playlists = $this->playlists()
->where('is_active', true)
->get();

View file

@ -60,6 +60,7 @@ class Playlist extends Model
}
// Get active playlist items ordered by display order
/** @var \Illuminate\Support\Collection|PlaylistItem[] $playlistItems */
$playlistItems = $this->items()
->where('is_active', true)
->orderBy('order')

View file

@ -2,6 +2,7 @@
namespace App\Models;
use Exception;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -138,7 +139,9 @@ class PlaylistItem extends Model
{
if (! $this->isMashup()) {
return view('trmnl-layouts.single', [
'slot' => $this->plugin->render('full', false),
'slot' => $this->plugin instanceof Plugin
? $this->plugin->render('full', false)
: throw new Exception('Invalid plugin instance'),
])->render();
}

View file

@ -57,7 +57,7 @@ class ImageGenerationService
case ImageFormat::PNG_8BIT_GRAYSCALE->value:
case ImageFormat::PNG_8BIT_256C->value:
try {
self::convertToPngImageMagick($pngPath, $device->width, $device->height, $device->rotate, quantize: $device->image_format === ImageFormat::PNG_8BIT_GRAYSCALE);
self::convertToPngImageMagick($pngPath, $device->width, $device->height, $device->rotate, quantize: $device->image_format === ImageFormat::PNG_8BIT_GRAYSCALE->value);
} catch (ImagickException $e) {
throw new RuntimeException('Failed to convert image to PNG: '.$e->getMessage(), 0, $e);
}