<?php
namespace Whater\Domain\Zones\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 Whater\Domain\Common\Exception\InvalidUUIDException;
use Whater\Domain\User\Model\User;
/**
* Class UbicationComment
*
* @package Whater\Domain\Whater\Model
*/
class UbicationComment implements ContainsRecordedEvents
{
use EventRecorderCapabilities;
/**
* @var string
*/
private $uuid;
/**
* @var string
*/
private $text;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var User
*/
private $createdBy;
/**
* @var Ubication
*/
private $ubication;
public function __construct(
string $uuid = null,
Ubication $ubication,
User $createdBy,
int $text = null
) {
try {
$this->uuid = Uuid::fromString($uuid ?: Uuid::uuid4())->toString();
} catch (\InvalidArgumentException $e) {
throw new InvalidUUIDException();
}
$this->ubication = $ubication;
$this->createdBy = $createdBy;
$this->text = $text;
$this->createdAt = new \DateTime();
}
/**
* @return Ubication
*/
public function ubication(): Ubication
{
return $this->ubication;
}
/**
* @return User
*/
public function createdBy(): User
{
return $this->createdBy;
}
/**
* @return \DateTime
*/
public function createdAt(): \DateTime
{
return $this->createdAt;
}
/**
* @return string
*/
public function text(): string
{
return $this->text;
}
}