iptv/src/app/Core/Playlist.php

46 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
declare(strict_types = 1);
namespace App\Core;
class Playlist extends BasicPlaylist
{
public ?string $name;
public ?string $desc;
public string $pls;
public ?string $src;
public string $url;
/**
* @throws \Exception
*/
public function __construct(public string $id, array $params)
{
empty($params['pls']) && throw new \Exception(
"Плейлист с ID=$id обязан иметь параметр pls или redirect"
);
$this->url = str_replace(['http://', 'https://'], '', base_url($id));
$this->name = $params['name'] ?? "Плейлист #$id";
$this->desc = $params['desc'] ?? null;
$this->pls = $params['pls'];
$this->src = $params['src'] ?? null;
}
public function toArray(): array
{
return [
'id' => $this->id,
'url' => $this->url,
'name' => $this->name,
'desc' => $this->desc,
'pls' => $this->pls,
'src' => $this->src,
];
}
}