test: resolve phpstan issues

This commit is contained in:
Benjamin Nussbaum 2025-09-24 19:35:06 +02:00
parent a1a57014b6
commit c67a182cf2
3 changed files with 42 additions and 15 deletions

View file

@ -10,6 +10,9 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\Storage;
/**
* @property-read DeviceModel|null $deviceModel
*/
class Device extends Model
{
use HasFactory;
@ -188,6 +191,30 @@ class Device extends Model
return $this->belongsTo(DeviceModel::class);
}
/**
* Get the color depth string (e.g., "4bit") for the associated device model.
*/
public function colorDepth(): ?string
{
return $this->deviceModel?->color_depth;
}
/**
* Get the scale level (e.g., large/xlarge/xxlarge) for the associated device model.
*/
public function scaleLevel(): ?string
{
return $this->deviceModel?->scale_level;
}
/**
* Get the device variant name, defaulting to 'og' if not available.
*/
public function deviceVariant(): string
{
return $this->deviceModel->name ?? 'og';
}
public function logs(): HasMany
{
return $this->hasMany(DeviceLog::class);

View file

@ -139,9 +139,9 @@ class PlaylistItem extends Model
{
if (! $this->isMashup()) {
return view('trmnl-layouts.single', [
'colorDepth' => $device?->deviceModel?->color_depth,
'deviceVariant' => $device?->deviceModel->name ?? 'og',
'scaleLevel' => $device?->deviceModel?->scale_level,
'colorDepth' => $device?->colorDepth(),
'deviceVariant' => $device?->deviceVariant() ?? 'og',
'scaleLevel' => $device?->scaleLevel(),
'slot' => $this->plugin instanceof Plugin
? $this->plugin->render('full', false)
: throw new Exception('Invalid plugin instance'),
@ -163,9 +163,9 @@ class PlaylistItem extends Model
}
return view('trmnl-layouts.mashup', [
'colorDepth' => $device?->deviceModel?->color_depth,
'deviceVariant' => $device?->deviceModel->name ?? 'og',
'scaleLevel' => $device?->deviceModel?->scale_level,
'colorDepth' => $device?->colorDepth(),
'deviceVariant' => $device?->deviceVariant() ?? 'og',
'scaleLevel' => $device?->scaleLevel(),
'mashupLayout' => $this->getMashupLayoutType(),
'slot' => implode('', $pluginMarkups),
])->render();

View file

@ -345,18 +345,18 @@ class Plugin extends Model
if ($standalone) {
if ($size === 'full') {
return view('trmnl-layouts.single', [
'colorDepth' => $device?->deviceModel?->color_depth,
'deviceVariant' => $device?->deviceModel->name ?? 'og',
'scaleLevel' => $device?->deviceModel?->scale_level,
'colorDepth' => $device?->colorDepth(),
'deviceVariant' => $device?->deviceVariant() ?? 'og',
'scaleLevel' => $device?->scaleLevel(),
'slot' => $renderedContent,
])->render();
}
return view('trmnl-layouts.mashup', [
'mashupLayout' => $this->getPreviewMashupLayoutForSize($size),
'colorDepth' => $device?->deviceModel?->color_depth,
'deviceVariant' => $device?->deviceModel->name ?? 'og',
'scaleLevel' => $device?->deviceModel?->scale_level,
'colorDepth' => $device?->colorDepth(),
'deviceVariant' => $device?->deviceVariant() ?? 'og',
'scaleLevel' => $device?->scaleLevel(),
'slot' => $renderedContent,
])->render();
@ -368,9 +368,9 @@ class Plugin extends Model
if ($this->render_markup_view) {
if ($standalone) {
return view('trmnl-layouts.single', [
'colorDepth' => $device?->deviceModel?->color_depth,
'deviceVariant' => $device?->deviceModel->name ?? 'og',
'scaleLevel' => $device?->deviceModel?->scale_level,
'colorDepth' => $device?->colorDepth(),
'deviceVariant' => $device?->deviceVariant() ?? 'og',
'scaleLevel' => $device?->scaleLevel(),
'slot' => view($this->render_markup_view, [
'size' => $size,
'data' => $this->data_payload,