slovocast/app/src/Domain/Entity/Channel.php

129 lines
2.6 KiB
PHP

<?php
namespace Slovocast\Domain\Entity;
use Slovocast\Domain\Entity;
class Channel
{
use Entity;
public function __construct(
private string $name,
private string $slug,
private string $description,
private ?string $link = '',
private ?string $language = '',
private ?string $copyright = '',
private ?bool $explicit = false,
) {}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): Channel
{
$this->name = $name;
return $this;
}
public function getSlug(): string
{
return $this->slug;
}
public function setSlug(string $slug): Channel
{
$this->slug = $slug;
return $this;
}
public function getDescription(): string
{
return $this->description;
}
public function setDescription(string $description): Channel
{
$this->description = $description;
return $this;
}
public function getLink(): string
{
return $this->link;
}
public function setLink(string $link): Channel
{
$this->link = $link;
return $this;
}
public function getLanguage(): string
{
return $this->language;
}
public function setLanguage(string $language): Channel
{
$this->language = $language;
return $this;
}
public function getCopyright(): string
{
return $this->copyright;
}
public function setCopyright(string $copyright): Channel
{
$this->copyright = $copyright;
return $this;
}
public function isExplicit(): bool
{
return $this->explicit;
}
public function setExplicit(bool $explicit): Channel
{
$this->explicit = $explicit;
return $this;
}
/**
* @param array $props The properties of the Channel model
* @return Channel
*/
public static function fromArray(array $props): Channel
{
$channel = new self(
$props['name'],
$props['slug'] ?? '',
$props['description'] ?? '',
$props['link'] ?? '',
$props['language'] ?? '',
$props['copyright'] ?? '',
$props['explicit'] ?? false
);
if (isset($props['id'])) {
$channel->setId($props['id']);
}
if (isset($props['createdAt'])) {
$channel->setCreatedAt($props['createdAt']);
}
if (isset($props['updatedAt'])) {
$channel->setUpdatedAt($props['updatedAt']);
}
return $channel;
}
}