<?php
namespace Whater\Domain\User\Model;
use BornFree\TacticianDomainEvent\Recorder\ContainsRecordedEvents;
use BornFree\TacticianDomainEvent\Recorder\EventRecorderCapabilities;
use Ramsey\Uuid\Uuid;
use Whater\Domain\Common\Exception\InvalidUUIDException;
use Whater\Domain\User\Model\User;
use Whater\Domain\Whater\Model\DistributionNetwork;
use Whater\Domain\Zones\Model\Ubication;
use Whater\Domain\Zones\Model\Town;
use Whater\Domain\Zones\Model\TownLocation;
/**
* Class OwnershipRequest
*
* @package Whater\Domain\User\Model
*/
class OwnershipRequest implements ContainsRecordedEvents
{
use EventRecorderCapabilities;
public const OR_STATUS_REQUEST = "OR_STATUS_REQUEST";
public const OR_STATUS_ACCEPTED = "OR_STATUS_ACCEPTED";
public const OR_STATUS_DENY = "OR_STATUS_DENY";
/**
* @var string
*/
private $uuid;
/**
* @var string
*/
private $status;
/**
* @var string
*/
private $message;
/**
* @var User
*/
private $user;
/**
* @var Ubication
*/
private $ubication;
/**
* @var Town
*/
private $town;
/**
* @var TownLocation
*/
private $townLocation;
/**
* @var DistributionNetwork
*/
private $distributionNetwork;
/**
* @var \DateTime
*/
private $createdAt;
public function __construct(
string $ownershipRequestId = null,
User $user,
Ubication $ubication = null,
Town $town = null,
DistributionNetwork $distributionNetwork = null,
string $message = null,
TownLocation $townLocation = null,
) {
try {
$this->uuid = Uuid::fromString($ownershipRequestId ?: Uuid::uuid4())->toString();
} catch (\InvalidArgumentException $e) {
throw new InvalidUUIDException();
}
$this->user = $user;
$this->ubication = $ubication;
$this->town = $town;
$this->townLocation = $townLocation;
$this->distributionNetwork = $distributionNetwork;
$this->status = OwnershipRequest::OR_STATUS_REQUEST;
$this->message = $message;
$this->createdAt = new \DateTime();
}
public function changeStatus(string $status){
$this->status = $status;
return $this;
}
/**
* @return string
*/
public function id(): string
{
return $this->uuid;
}
/**
* @return string
*/
public function status(): string
{
return $this->status;
}
/**
* @return string|null
*/
public function message(): ?string
{
return $this->message;
}
/**
* @return Ubication|null
*/
public function ubication(): ?Ubication
{
return $this->ubication;
}
/**
* @return Town|null
*/
public function town(): ?Town
{
return $this->town;
}
/**
* @return TownLocation|null
*/
public function townLocation(): ?TownLocation
{
return $this->townLocation;
}
/**
* @return DistributionNetwork|null
*/
public function distributionNetwork(): ?DistributionNetwork
{
return $this->distributionNetwork;
}
/**
* @return User
*/
public function user(): User
{
return $this->user;
}
/**
* @return \DateTime
*/
public function createdAt(): \DateTime
{
return $this->createdAt;
}
}