<?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 WhaterWidgetLog
*
* @package Whater\Domain\Whater\Model
*/
class WhaterWidgetLog implements ContainsRecordedEvents
{
use EventRecorderCapabilities;
/**
* @var string
*/
private $uuid;
/**
* @var string
*/
private $browser;
/**
* @var string
*/
private $ip;
/**
* @var string
*/
private $apikey;
/**
* @var WhaterPoint
*/
private $whaterPoint;
/**
* @var DistributionNetwork
*/
private $distributionNetwork;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @param string $browser
* @param string $ip
* @param WhaterPoint $whaterPoint
*/
public function __construct(
string $browser = null,
string $ip = null,
string $apikey = null,
WhaterPoint $whaterPoint = null,
DistributionNetwork $distributionNetwork = null
) {
try {
$this->uuid = Uuid::fromString(Uuid::uuid4())->toString();
} catch (\InvalidArgumentException $e) {
throw new InvalidUUIDException();
}
$this->browser = $browser;
$this->ip = $ip;
$this->apikey = $apikey;
$this->whaterPoint = $whaterPoint;
$this->distributionNetwork = $distributionNetwork;
$this->createdAt = new \DateTime();
}
/**
* @return string
*/
public function id(): string
{
return $this->uuid;
}
/**
* @return string
*/
public function browser(): string
{
return $this->browser;
}
/**
* @return string
*/
public function ip(): string
{
return $this->ip;
}
/**
* @return string
*/
public function apikey(): string
{
return $this->apikey;
}
/**
* @return WhaterPoint
*/
public function whaterPoint(): ?WhaterPoint
{
return $this->whaterPoint;
}
/**
* @return DistributionNetwork
*/
public function distributionNetwork(): ?DistributionNetwork
{
return $this->distributionNetwork;
}
/**
* @return \DateTime
*/
public function createdAt(): \DateTime
{
return $this->createdAt;
}
}