src/Domain/Whater/Model/WhaterWidgetLog.php line 15

Open in your IDE?
  1. <?php
  2. namespace Whater\Domain\Whater\Model;
  3. use BornFree\TacticianDomainEvent\Recorder\ContainsRecordedEvents;
  4. use BornFree\TacticianDomainEvent\Recorder\EventRecorderCapabilities;
  5. use Ramsey\Uuid\Uuid;
  6. use Whater\Domain\Common\Exception\InvalidUUIDException;
  7. /**
  8. * Class WhaterWidgetLog
  9. *
  10. * @package Whater\Domain\Whater\Model
  11. */
  12. class WhaterWidgetLog implements ContainsRecordedEvents
  13. {
  14. use EventRecorderCapabilities;
  15. /**
  16. * @var string
  17. */
  18. private $uuid;
  19. /**
  20. * @var string
  21. */
  22. private $browser;
  23. /**
  24. * @var string
  25. */
  26. private $ip;
  27. /**
  28. * @var string
  29. */
  30. private $apikey;
  31. /**
  32. * @var WhaterPoint
  33. */
  34. private $whaterPoint;
  35. /**
  36. * @var DistributionNetwork
  37. */
  38. private $distributionNetwork;
  39. /**
  40. * @var \DateTime
  41. */
  42. private $createdAt;
  43. /**
  44. * @param string $browser
  45. * @param string $ip
  46. * @param WhaterPoint $whaterPoint
  47. */
  48. public function __construct(
  49. string $browser = null,
  50. string $ip = null,
  51. string $apikey = null,
  52. WhaterPoint $whaterPoint = null,
  53. DistributionNetwork $distributionNetwork = null
  54. ) {
  55. try {
  56. $this->uuid = Uuid::fromString(Uuid::uuid4())->toString();
  57. } catch (\InvalidArgumentException $e) {
  58. throw new InvalidUUIDException();
  59. }
  60. $this->browser = $browser;
  61. $this->ip = $ip;
  62. $this->apikey = $apikey;
  63. $this->whaterPoint = $whaterPoint;
  64. $this->distributionNetwork = $distributionNetwork;
  65. $this->createdAt = new \DateTime();
  66. }
  67. /**
  68. * @return string
  69. */
  70. public function id(): string
  71. {
  72. return $this->uuid;
  73. }
  74. /**
  75. * @return string
  76. */
  77. public function browser(): string
  78. {
  79. return $this->browser;
  80. }
  81. /**
  82. * @return string
  83. */
  84. public function ip(): string
  85. {
  86. return $this->ip;
  87. }
  88. /**
  89. * @return string
  90. */
  91. public function apikey(): string
  92. {
  93. return $this->apikey;
  94. }
  95. /**
  96. * @return WhaterPoint
  97. */
  98. public function whaterPoint(): ?WhaterPoint
  99. {
  100. return $this->whaterPoint;
  101. }
  102. /**
  103. * @return DistributionNetwork
  104. */
  105. public function distributionNetwork(): ?DistributionNetwork
  106. {
  107. return $this->distributionNetwork;
  108. }
  109. /**
  110. * @return \DateTime
  111. */
  112. public function createdAt(): \DateTime
  113. {
  114. return $this->createdAt;
  115. }
  116. }