Add the Entity trait to the channel.

This commit is contained in:
Dave Smith-Hayes 2024-05-29 21:44:03 -04:00
parent 5a86bb3579
commit 8d7bcd0c2a

View File

@ -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;
}
}