<?phpnamespace App\Cast;/** A screen of the network WinZik can cast to: a Google Cast device (Chromecast, Android TV...) or a DLNA renderer. */final class CastDevice{ public const CAST = 'cast'; public const DLNA = 'dlna'; public function __construct( public string $kind, public string $id, public string $name, public string $model, public string $host, public int $port, /** DLNA: the control address of AVTransport ('' for Cast) */ public string $avTransport = '', /** DLNA: the control address of RenderingControl (the volume; '' none) */ public string $rendering = '', public float $seen = 0.0, ) { } /** "Salon (Chromecast)", "Téléviseur [TV] Samsung (DLNA)" */ public function label(): string { $what = $this->kind === self::CAST ? ($this->model !== '' ? $this->model : 'Google Cast') : 'DLNA'; return $this->name . ' (' . $what . ')'; } /** What it can do: Cast shows a page (custom receiver) or plays; DLNA only plays. */ public function canShowPage(): bool { return $this->kind === self::CAST; } /** @return array<string, mixed> */ public function toArray(): array { return ['kind' => $this->kind, 'id' => $this->id, 'name' => $this->name, 'model' => $this->model, 'host' => $this->host, 'port' => $this->port, 'label' => $this->label()]; }}