src/JanusHercules/GohiringIntegration/Domain/Entity/GohiringPositionEvent.php line 16

Open in your IDE?
  1. <?php
  2. namespace JanusHercules\GohiringIntegration\Domain\Entity;
  3. use App\Utility\DatabaseIdGenerator;
  4. use App\Utility\DateTimeUtility;
  5. use DateTime;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Exception;
  9. use JanusHercules\GohiringIntegration\Domain\Enum\GohiringPositionEventSource;
  10. use JanusHercules\GohiringIntegration\Domain\Enum\GohiringPositionEventType;
  11. #[ORM\Entity]
  12. #[ORM\Table(name: 'gi_gohiring_position_events')]
  13. class GohiringPositionEvent
  14. {
  15. /**
  16. * @throws Exception
  17. */
  18. public function __construct(
  19. string $positionId,
  20. GohiringPositionEventType $eventType,
  21. ?DateTime $expiresAtReported = null,
  22. bool $isSuccess = true,
  23. string $info = '',
  24. ?DateTime $occuredAt = null,
  25. GohiringPositionEventSource $source = GohiringPositionEventSource::LIVE,
  26. ) {
  27. $this->positionId = $positionId;
  28. $this->occuredAt = is_null($occuredAt) ? DateTimeUtility::createDateTimeUtc() : $occuredAt;
  29. $this->eventType = $eventType;
  30. $this->expiresAtReported = $expiresAtReported;
  31. $this->isSuccess = $isSuccess;
  32. $this->info = $info;
  33. $this->source = $source;
  34. }
  35. #[ORM\Id]
  36. #[ORM\GeneratedValue(strategy: 'CUSTOM')]
  37. #[ORM\CustomIdGenerator(class: DatabaseIdGenerator::class)]
  38. #[ORM\Column(
  39. type : Types::GUID,
  40. unique: true
  41. )]
  42. private ?string $id = null;
  43. public function getId(): ?string
  44. {
  45. return $this->id;
  46. }
  47. #[ORM\Column(
  48. type : Types::GUID,
  49. unique: false
  50. )]
  51. private readonly string $positionId;
  52. public function getPositionId(): string
  53. {
  54. return $this->positionId;
  55. }
  56. #[ORM\Column(
  57. type : Types::STRING,
  58. enumType: GohiringPositionEventType::class
  59. )]
  60. private readonly GohiringPositionEventType $eventType;
  61. public function getEventType(): GohiringPositionEventType
  62. {
  63. return $this->eventType;
  64. }
  65. #[ORM\Column(
  66. type : Types::DATETIME_MUTABLE,
  67. nullable: false
  68. )]
  69. private readonly DateTime $occuredAt;
  70. public function getOccuredAt(): DateTime
  71. {
  72. return $this->occuredAt;
  73. }
  74. #[ORM\Column(
  75. type : Types::DATETIME_MUTABLE,
  76. nullable: true
  77. )]
  78. private ?DateTime $expiresAtReported;
  79. public function getExpiresAtReported(): ?DateTime
  80. {
  81. return $this->expiresAtReported;
  82. }
  83. #[ORM\Column(
  84. type : Types::BOOLEAN,
  85. nullable: false
  86. )]
  87. private bool $isSuccess;
  88. public function isSuccess(): bool
  89. {
  90. return $this->isSuccess;
  91. }
  92. #[ORM\Column(
  93. type : Types::TEXT,
  94. nullable: false
  95. )]
  96. private string $info;
  97. public function getInfo(): string
  98. {
  99. return $this->info;
  100. }
  101. #[ORM\Column(
  102. type : Types::STRING,
  103. enumType: GohiringPositionEventSource::class
  104. )]
  105. private readonly GohiringPositionEventSource $source;
  106. public function getSource(): GohiringPositionEventSource
  107. {
  108. return $this->source;
  109. }
  110. }