src/Entity/SeasonGoogleChatMessageType.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SeasonGoogleChatMessageTypeRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassSeasonGoogleChatMessageTypeRepository::class)]
  7. class SeasonGoogleChatMessageType
  8. {
  9.     public const TYPE_DAILY_DIGEST 'daily_digest';
  10.     public const TYPE_YESTERDAY_DIGEST 'yesterday_digest';
  11.     public const TYPE_WEEKLY_DIGEST 'weekly_digest';
  12.     public const TYPE_NEW_LEADER 'new_leader';
  13.     public const TYPE_CLOSE_RACE 'close_race';
  14.     public const TYPE_MILESTONE 'milestone_achieved';
  15.     public const TYPE_COMEBACK 'comeback_alert';
  16.     public const TYPE_MOTIVATIONAL 'motivational';
  17.     public const TYPE_TRASH_TALK 'trash_talk';
  18.     public const TYPES = [
  19.         self::TYPE_DAILY_DIGEST => 'Daily Digest',
  20.         self::TYPE_YESTERDAY_DIGEST => 'Yesterday Digest',
  21.         self::TYPE_WEEKLY_DIGEST => 'Weekly Digest',
  22.         self::TYPE_NEW_LEADER => 'New Leader Alert',
  23.         self::TYPE_CLOSE_RACE => 'Close Race Alert',
  24.         self::TYPE_MILESTONE => 'Milestone Achieved',
  25.         self::TYPE_COMEBACK => 'Comeback Alert',
  26.         self::TYPE_MOTIVATIONAL => 'Motivational Messages',
  27.         self::TYPE_TRASH_TALK => 'Trash Talk Notifications',
  28.     ];
  29.     #[ORM\Id]
  30.     #[ORM\GeneratedValue]
  31.     #[ORM\Column]
  32.     private ?int $id null;
  33.     #[ORM\ManyToOne(inversedBy'messageTypes')]
  34.     #[ORM\JoinColumn(nullablefalse)]
  35.     private ?SeasonGoogleChatConfig $googleChatConfig null;
  36.     #[ORM\Column(length50)]
  37.     private ?string $messageType null;
  38.     #[ORM\Column]
  39.     private ?bool $isEnabled true;
  40.     #[ORM\Column(typeTypes::TIME_MUTABLEnullabletrue)]
  41.     private ?\DateTimeInterface $scheduleTime null;
  42.     #[ORM\Column(nullabletrue)]
  43.     private ?int $scheduleDay null;
  44.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  45.     private ?array $config null;
  46.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  47.     private ?\DateTimeInterface $createdAt null;
  48.     public function __construct()
  49.     {
  50.         $this->createdAt = new \DateTime();
  51.     }
  52.     public function __toString(): string
  53.     {
  54.         return self::TYPES[$this->messageType] ?? $this->messageType;
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getGoogleChatConfig(): ?SeasonGoogleChatConfig
  61.     {
  62.         return $this->googleChatConfig;
  63.     }
  64.     public function setGoogleChatConfig(?SeasonGoogleChatConfig $googleChatConfig): static
  65.     {
  66.         $this->googleChatConfig $googleChatConfig;
  67.         return $this;
  68.     }
  69.     public function getMessageType(): ?string
  70.     {
  71.         return $this->messageType;
  72.     }
  73.     public function setMessageType(string $messageType): static
  74.     {
  75.         $this->messageType $messageType;
  76.         return $this;
  77.     }
  78.     public function isIsEnabled(): ?bool
  79.     {
  80.         return $this->isEnabled;
  81.     }
  82.     public function setIsEnabled(bool $isEnabled): static
  83.     {
  84.         $this->isEnabled $isEnabled;
  85.         return $this;
  86.     }
  87.     public function getScheduleTime(): ?\DateTimeInterface
  88.     {
  89.         return $this->scheduleTime;
  90.     }
  91.     public function setScheduleTime(?\DateTimeInterface $scheduleTime): static
  92.     {
  93.         $this->scheduleTime $scheduleTime;
  94.         return $this;
  95.     }
  96.     public function getScheduleDay(): ?int
  97.     {
  98.         return $this->scheduleDay;
  99.     }
  100.     public function setScheduleDay(?int $scheduleDay): static
  101.     {
  102.         $this->scheduleDay $scheduleDay;
  103.         return $this;
  104.     }
  105.     public function getConfig(): ?array
  106.     {
  107.         return $this->config;
  108.     }
  109.     public function setConfig(?array $config): static
  110.     {
  111.         $this->config $config;
  112.         return $this;
  113.     }
  114.     public function getCreatedAt(): ?\DateTimeInterface
  115.     {
  116.         return $this->createdAt;
  117.     }
  118.     public function setCreatedAt(\DateTimeInterface $createdAt): static
  119.     {
  120.         $this->createdAt $createdAt;
  121.         return $this;
  122.     }
  123.     /**
  124.      * Check if this is a scheduled message type
  125.      */
  126.     public function isScheduledType(): bool
  127.     {
  128.         return in_array($this->messageType, [
  129.             self::TYPE_DAILY_DIGEST,
  130.             self::TYPE_YESTERDAY_DIGEST,
  131.             self::TYPE_WEEKLY_DIGEST,
  132.             self::TYPE_MOTIVATIONAL,
  133.         ]);
  134.     }
  135.     /**
  136.      * Get a configuration value
  137.      */
  138.     public function getConfigValue(string $keymixed $default null): mixed
  139.     {
  140.         return $this->config[$key] ?? $default;
  141.     }
  142.     /**
  143.      * Set a configuration value
  144.      */
  145.     public function setConfigValue(string $keymixed $value): static
  146.     {
  147.         $config $this->config ?? [];
  148.         $config[$key] = $value;
  149.         $this->config $config;
  150.         return $this;
  151.     }
  152. }