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

42 lines
792 B
PHP

<?php
namespace Slovocast\Domain\Entity;
use Slovocast\Domain\Entity as EntityTrait;
class Category
{
use EntityTrait;
public function __construct(
private string $name
) { }
public function getName(): string
{
return $this->name;
}
/**
* @param array $props Key is each property of the entity
*/
public static function fromArray(array $props): self
{
$category = new self($props['name']);
if ($props['id']) {
$category->setId($props['id']);
}
if ($props['createdAt']) {
$category->setCreatedAt($props['createdAt']);
}
if ($props['updatedAt']) {
$category->setUpdatedAt($props['updatedAt']);
}
return $category;
}
}