<?phpnamespace Whater\Domain\Whater\Model;use Ramsey\Uuid\Uuid;use Whater\Domain\Common\Exception\InvalidUUIDException;use Whater\Domain\User\Model\User;use Whater\Domain\Product\Model\CartOrder;use Whater\Domain\User\Model\UserNfc;/** * Class WhaterRefill * * @package Whater\Domain\Whater\Model */class WhaterRefill{ public const DEFAULT_MILLIMETERS = 100; /** * @var string */ private $uuid; /** * @var WhaterPoint */ private $whaterPoint; /** * @var UserNfc */ private $userNfc; /** * @var CartOrder */ private $cartOrder; /** * @var User */ private $user; /** * @var float */ private $milliliters; /** * @var \DateTime */ private $createdAt; /** * @var \DateTime */ private $updatedAt; /** * @var bool */ private $confirmed; /** * @param string $whaterRefill * @param Whaterpoint $whaterPoint * @param float $latitude * @param float $longitude * @param DistributionNetwork $distributionNetwork */ public function __construct( ?string $whaterRefillId = null, WhaterPoint $whaterPoint, ?User $user = null, ?CartOrder $cartOrder = null, float $milliliters = WhaterRefill::DEFAULT_MILLIMETERS, ?UserNfc $userNfc = null ) { try { $this->uuid = Uuid::fromString($whaterRefillId ?: Uuid::uuid4())->toString(); } catch (\InvalidArgumentException $e) { throw new InvalidUUIDException(); } $this->whaterPoint = $whaterPoint; $this->user = $user; $this->cartOrder = $cartOrder; $this->milliliters = $milliliters; $this->userNfc = $userNfc; $this->confirmed = false; $this->createdAt = new \DateTime(); $this->updatedAt = $this->createdAt; } public function confirmRefill( bool $confirmed ) { $this->confirmed = $confirmed; $this->updatedAt = new \DateTime(); return $this; } /** * @return string */ public function id(): string { return $this->uuid; } /** * @return WhaterPoint */ public function whaterPoint(): WhaterPoint { return $this->whaterPoint; } /** * @return User */ public function user(): ?User { return $this->user; } /** * @return UserNfc */ public function userNfc(): ?UserNfc { return $this->userNfc; } /** * @return CartOrder */ public function cartOrder(): ?CartOrder { return $this->cartOrder; } /** * @return float */ public function milliliters(): float { return $this->milliliters; } /** * @return bool */ public function confirmed(): bool { return $this->confirmed; } /** * @return \DateTime */ public function createdAt(): \DateTime { return $this->createdAt; } /** * @return \DateTime */ public function updatedAt(): \DateTime { return $this->updatedAt; }}