src/Domain/Zones/Model/UbicationComment.php line 18

Open in your IDE?
  1. <?php
  2. namespace Whater\Domain\Zones\Model;
  3. use BornFree\TacticianDomainEvent\Recorder\ContainsRecordedEvents;
  4. use BornFree\TacticianDomainEvent\Recorder\EventRecorderCapabilities;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Ramsey\Uuid\Uuid;
  8. use Whater\Domain\Common\Exception\InvalidUUIDException;
  9. use Whater\Domain\User\Model\User;
  10. /**
  11. * Class UbicationComment
  12. *
  13. * @package Whater\Domain\Whater\Model
  14. */
  15. class UbicationComment implements ContainsRecordedEvents
  16. {
  17. use EventRecorderCapabilities;
  18. /**
  19. * @var string
  20. */
  21. private $uuid;
  22. /**
  23. * @var string
  24. */
  25. private $text;
  26. /**
  27. * @var \DateTime
  28. */
  29. private $createdAt;
  30. /**
  31. * @var User
  32. */
  33. private $createdBy;
  34. /**
  35. * @var Ubication
  36. */
  37. private $ubication;
  38. public function __construct(
  39. string $uuid = null,
  40. Ubication $ubication,
  41. User $createdBy,
  42. int $text = null
  43. ) {
  44. try {
  45. $this->uuid = Uuid::fromString($uuid ?: Uuid::uuid4())->toString();
  46. } catch (\InvalidArgumentException $e) {
  47. throw new InvalidUUIDException();
  48. }
  49. $this->ubication = $ubication;
  50. $this->createdBy = $createdBy;
  51. $this->text = $text;
  52. $this->createdAt = new \DateTime();
  53. }
  54. /**
  55. * @return Ubication
  56. */
  57. public function ubication(): Ubication
  58. {
  59. return $this->ubication;
  60. }
  61. /**
  62. * @return User
  63. */
  64. public function createdBy(): User
  65. {
  66. return $this->createdBy;
  67. }
  68. /**
  69. * @return \DateTime
  70. */
  71. public function createdAt(): \DateTime
  72. {
  73. return $this->createdAt;
  74. }
  75. /**
  76. * @return string
  77. */
  78. public function text(): string
  79. {
  80. return $this->text;
  81. }
  82. }