<?php
namespace 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;
/**
* Class WhaterRefill
*
* @package Whater\Domain\Whater\Model
*/
class WhaterRefill
{
/**
* @var string
*/
private $uuid;
/**
* @var WhaterPoint
*/
private $whaterPoint;
/**
* @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 = 100
) {
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->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 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;
}
}