src/JanusHercules/ExternallyIncomingApplications/Domain/Entity/ExternallyIncomingApplication.php line 15

Open in your IDE?
  1. <?php
  2. namespace JanusHercules\ExternallyIncomingApplications\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\ExternallyIncomingApplications\Domain\Enum\FunnelId;
  10. #[ORM\Entity]
  11. #[ORM\Table(name: 'externally_incoming_applications')]
  12. class ExternallyIncomingApplication
  13. {
  14. public const SOURCE_PERSPECTIVE = 0;
  15. /**
  16. * @throws Exception
  17. */
  18. public function __construct(
  19. int $source,
  20. string $content,
  21. ?FunnelId $funnelId
  22. ) {
  23. $this->source = $source;
  24. $this->setContent($content);
  25. $this->createdAt = DateTimeUtility::createDateTimeCet();
  26. $this->funnelId = $funnelId;
  27. }
  28. #[ORM\Id]
  29. #[ORM\GeneratedValue(strategy: 'CUSTOM')]
  30. #[ORM\CustomIdGenerator(class: DatabaseIdGenerator::class)]
  31. #[ORM\Column(
  32. type : Types::GUID,
  33. unique: true
  34. )]
  35. private ?string $id = null;
  36. public function getId(): ?string
  37. {
  38. return $this->id;
  39. }
  40. #[ORM\Column(
  41. type : Types::INTEGER,
  42. nullable: false
  43. )]
  44. private int $source;
  45. public function getSource(): int
  46. {
  47. return $this->source;
  48. }
  49. #[ORM\Column(
  50. type : Types::STRING,
  51. nullable: true,
  52. enumType: FunnelId::class
  53. )]
  54. private ?FunnelId $funnelId;
  55. public function getFunnelId(): ?FunnelId
  56. {
  57. return $this->funnelId;
  58. }
  59. #[ORM\Column(
  60. type : Types::DATETIME_MUTABLE,
  61. nullable: false
  62. )]
  63. private DateTime $createdAt;
  64. public function setCreatedAt(DateTime $createdAt): void
  65. {
  66. $this->createdAt = $createdAt;
  67. }
  68. public function getCreatedAt(): DateTime
  69. {
  70. return $this->createdAt;
  71. }
  72. #[ORM\Column(
  73. type : Types::TEXT,
  74. length : 32768,
  75. nullable: false
  76. )]
  77. private string $content;
  78. public function setContent(string $content): void
  79. {
  80. $this->content = mb_substr($content, 0, 32768);
  81. }
  82. public function getContent(): string
  83. {
  84. return $this->content;
  85. }
  86. }