<?phpnamespace Whater\Domain\Blog\Model;use BornFree\TacticianDomainEvent\Recorder\ContainsRecordedEvents;use BornFree\TacticianDomainEvent\Recorder\EventRecorderCapabilities;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Ramsey\Uuid\Uuid;use Assert\Assertion;use Whater\Domain\Common\Exception\InvalidUUIDException;/** * Class ArticleCategoryTranslation * * @package Whater\Domain\Blog\Model */class ArticleCategoryTranslation implements ContainsRecordedEvents{ use EventRecorderCapabilities; /** * @var string */ private $uuid; /** * @var string */ private $title; /** * @var string */ private $slug; /** * @var ArticleCategory */ private $articleCategory; /** * @var string */ private $locale; /** * @var null|\DateTime */ private $createdAt; /** * @var null|\DateTime */ private $updatedAt; public function __construct( string $articleCategoryTranslationId = null, ArticleCategory $articlecategory, string $locale, string $title, string $slug ) { try { $this->uuid = Uuid::fromString($articleCategoryTranslationId ?: Uuid::uuid4())->toString(); } catch (\InvalidArgumentException $e) { throw new InvalidUUIDException(); } $this->articleCategory = $articlecategory; $this->locale = $locale; $this->title = $title; $this->slug = $slug; $this->createdAt = new \DateTime(); $this->updatedAt = $this->createdAt(); } public function updateArticleCategoryTranslation( string $title = null, string $slug = null ): ArticleCategoryTranslation { if (!is_null($title)) { $this->title = $title; } if (!is_null($slug)) { $this->slug = $slug; } $this->updatedAt = new \DateTime(); return $this; } /** * @return string */ public function id(): string { return $this->uuid; } /** * @return string */ public function title(): string { return $this->title; } /** * @return string */ public function slug(): string { return $this->slug; } /** * @return string */ public function locale(): string { return $this->locale; } /** * @return \DateTime */ public function createdAt(): \DateTime { return $this->createdAt; } /** * @return \DateTime */ public function updatedAt(): \DateTime { return $this->updatedAt; }}