<?php
namespace Whater\Domain\Whater\Model;
use BornFree\TacticianDomainEvent\Recorder\ContainsRecordedEvents;
use BornFree\TacticianDomainEvent\Recorder\EventRecorderCapabilities;
use Ramsey\Uuid\Uuid;
use Whater\Domain\Common\Exception\InvalidUUIDException;
/**
* Class WhaterPointAttributeTypeChoice
*
* @package Whater\Domain\Whater\Model
*/
class WhaterPointAttributeTypeChoice implements ContainsRecordedEvents
{
use EventRecorderCapabilities;
/**
* @var string
*/
private $uuid;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var \DateTime
*/
private $updatedAt;
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $slug;
/**
* @var WhaterPointAttributeType
*/
private $attributeType;
public function __construct(
string $whaterPointAttributeTypeId = null,
string $name,
string $slug,
string $attributeType
) {
try {
$this->uuid = Uuid::fromString($whaterPointAttributeTypeId ?: Uuid::uuid4())->toString();
} catch (\InvalidArgumentException $e) {
throw new InvalidUUIDException();
}
$this->name = $name;
$this->slug = $slug;
$this->attributeType = $attributeType;
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
}
public function updateAttributeTypeChoice(
string $name,
string $slug = null
) {
$this->name = $name;
if ($slug != null) {
$this->slug = $slug;
}
$this->updatedAt = new \DateTime();
return $this;
}
/**
* @return string
*/
public function id(): string
{
return $this->uuid;
}
/**
* @return string
*/
public function name(): string
{
return $this->name;
}
/**
* @return string
*/
public function slug(): string
{
return $this->slug;
}
/**
* @return WhaterPointAttributeType
*/
public function attributeType(): WhaterPointAttributeType
{
return $this->attributeType;
}
/**
* @return \DateTime
*/
public function createdAt(): \DateTime
{
return $this->createdAt;
}
/**
* @return \DateTime
*/
public function updatedAt(): \DateTime
{
return $this->updatedAt;
}
/**
* @return bool
*/
public function equals(WhaterPointAttributeTypeChoice $whaterPointAttributeTypeChoice)
{
return $this->id() === $whaterPointAttributeTypeChoice->id();
}
}