<?php
namespace App\Entity;
use App\Repository\SeasonGoogleChatMessageTypeRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SeasonGoogleChatMessageTypeRepository::class)]
class SeasonGoogleChatMessageType
{
public const TYPE_DAILY_DIGEST = 'daily_digest';
public const TYPE_YESTERDAY_DIGEST = 'yesterday_digest';
public const TYPE_WEEKLY_DIGEST = 'weekly_digest';
public const TYPE_NEW_LEADER = 'new_leader';
public const TYPE_CLOSE_RACE = 'close_race';
public const TYPE_MILESTONE = 'milestone_achieved';
public const TYPE_COMEBACK = 'comeback_alert';
public const TYPE_MOTIVATIONAL = 'motivational';
public const TYPE_TRASH_TALK = 'trash_talk';
public const TYPES = [
self::TYPE_DAILY_DIGEST => 'Daily Digest',
self::TYPE_YESTERDAY_DIGEST => 'Yesterday Digest',
self::TYPE_WEEKLY_DIGEST => 'Weekly Digest',
self::TYPE_NEW_LEADER => 'New Leader Alert',
self::TYPE_CLOSE_RACE => 'Close Race Alert',
self::TYPE_MILESTONE => 'Milestone Achieved',
self::TYPE_COMEBACK => 'Comeback Alert',
self::TYPE_MOTIVATIONAL => 'Motivational Messages',
self::TYPE_TRASH_TALK => 'Trash Talk Notifications',
];
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'messageTypes')]
#[ORM\JoinColumn(nullable: false)]
private ?SeasonGoogleChatConfig $googleChatConfig = null;
#[ORM\Column(length: 50)]
private ?string $messageType = null;
#[ORM\Column]
private ?bool $isEnabled = true;
#[ORM\Column(type: Types::TIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $scheduleTime = null;
#[ORM\Column(nullable: true)]
private ?int $scheduleDay = null;
#[ORM\Column(type: Types::JSON, nullable: true)]
private ?array $config = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $createdAt = null;
public function __construct()
{
$this->createdAt = new \DateTime();
}
public function __toString(): string
{
return self::TYPES[$this->messageType] ?? $this->messageType;
}
public function getId(): ?int
{
return $this->id;
}
public function getGoogleChatConfig(): ?SeasonGoogleChatConfig
{
return $this->googleChatConfig;
}
public function setGoogleChatConfig(?SeasonGoogleChatConfig $googleChatConfig): static
{
$this->googleChatConfig = $googleChatConfig;
return $this;
}
public function getMessageType(): ?string
{
return $this->messageType;
}
public function setMessageType(string $messageType): static
{
$this->messageType = $messageType;
return $this;
}
public function isIsEnabled(): ?bool
{
return $this->isEnabled;
}
public function setIsEnabled(bool $isEnabled): static
{
$this->isEnabled = $isEnabled;
return $this;
}
public function getScheduleTime(): ?\DateTimeInterface
{
return $this->scheduleTime;
}
public function setScheduleTime(?\DateTimeInterface $scheduleTime): static
{
$this->scheduleTime = $scheduleTime;
return $this;
}
public function getScheduleDay(): ?int
{
return $this->scheduleDay;
}
public function setScheduleDay(?int $scheduleDay): static
{
$this->scheduleDay = $scheduleDay;
return $this;
}
public function getConfig(): ?array
{
return $this->config;
}
public function setConfig(?array $config): static
{
$this->config = $config;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Check if this is a scheduled message type
*/
public function isScheduledType(): bool
{
return in_array($this->messageType, [
self::TYPE_DAILY_DIGEST,
self::TYPE_YESTERDAY_DIGEST,
self::TYPE_WEEKLY_DIGEST,
self::TYPE_MOTIVATIONAL,
]);
}
/**
* Get a configuration value
*/
public function getConfigValue(string $key, mixed $default = null): mixed
{
return $this->config[$key] ?? $default;
}
/**
* Set a configuration value
*/
public function setConfigValue(string $key, mixed $value): static
{
$config = $this->config ?? [];
$config[$key] = $value;
$this->config = $config;
return $this;
}
}