diff --git a/app/src/Domain/Entity/Channel.php b/app/src/Domain/Entity/Channel.php index f8f6369..e640bbc 100644 --- a/app/src/Domain/Entity/Channel.php +++ b/app/src/Domain/Entity/Channel.php @@ -2,10 +2,13 @@ namespace Slovocast\Domain\Entity; +use Slovocast\Domain\Entity; + class Channel { + use Entity; + public function __construct( - private readonly ?int $id, private string $name, private ?string $description = '', private ?string $link = '', @@ -45,8 +48,7 @@ class Channel */ public static function fromArray(array $props): Channel { - return self( - $props['id'] ?? null, + $channel = new self( $props['name'], $props['description'] ?? '', $props['link'] ?? '', @@ -54,5 +56,19 @@ class Channel $props['copyright'] ?? '', $props['explicit'] ?? false ); + + if ($props['id']) { + $channel->setId($props['id']); + } + + if ($props['createdAt']) { + $channel->setCreatedAt($props['createdAt']); + } + + if ($props['updatedAt']) { + $channel->setUpdatedAt($props['updatedAt']); + } + + return $channel; } }