<?php declare(strict_types=1);
namespace Sq\Entity\Schema\ORM;
use Doctrine\ORM\Mapping as ORM;
use Sq\Entity\Enum;
use Sq\Entity\Schema\Column;
#[ORM\Entity]
#[ORM\Table(name: 'user_organization_settings')]
class UserOrganizationSettings
{
protected const DEFAULT_DATE_FORMAT = Enum\DateFormatSetting::DAY_MONTH_YEAR;
protected const DEFAULT_TIME_FORMAT = Enum\TimeFormatSetting::HOUR_24;
protected const DEFAULT_START_OF_WEEK_FORMAT = Enum\StartOfWeekFormatSetting::SUNDAY;
/**
*
* @var int|null
*/
#[ORM\Id]
#[ORM\Column(name: 'uos_id', type: 'integer', nullable: false, options: ['unsigned' => true])]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
/**
*
* @var UserOrganizationAssignment
*/
#[ORM\OneToOne(targetEntity: UserOrganizationAssignment::class, inversedBy: 'settings', cascade: ['persist'])]
#[ORM\JoinColumn(name: 'uos_uoa_id', referencedColumnName: 'uoa_id', nullable: false)]
private $assignment;
/**
* @var string
*/
#[ORM\Column(name: 'uos_date_format', type: 'string', length: 191, nullable: false)]
private $dateFormat;
/**
* @var string
*/
#[ORM\Column(name: 'uos_time_format', type: 'string', length: 191, nullable: false)]
private $timeFormat;
/**
* @var string
*/
#[ORM\Column(name: 'uos_start_of_week_format', type: 'string', length: 191, nullable: false)]
private $startOfWeekFormat;
/**
* @var bool
*/
#[ORM\Column(name: 'uos_notify_weekly_stats', type: 'boolean', nullable: false, options: ['default' => true])]
private $notifyWeeklyStats = true;
/**
* @var bool
*/
#[ORM\Column(name: 'uos_notify_queue_empty', type: 'boolean', nullable: false, options: ['default' => true])]
private $notifyQueueEmpty = true;
/**
* @var bool
*/
#[ORM\Column(name: 'uos_notify_post_profile_error', type: 'boolean', nullable: false, options: ['default' => true])]
private $notifyPostProfileError = true;
/**
* @var bool
*/
#[ORM\Column(name: 'uos_notify_instagram_post', type: 'boolean', nullable: false, options: ['default' => false])]
private $notifyInstagramPost = false;
/**
* @var bool
*/
#[ORM\Column(name: 'uos_notify_auto_rss', type: 'boolean', nullable: false, options: ['default' => true])]
private $notifyAutoRss = true;
/**
* @var bool
*/
#[ORM\Column(name: 'uos_notify_social_essentials', type: 'boolean', nullable: false, options: ['default' => true])]
private bool $notifySocialEssentials = true;
public function __construct(UserOrganizationAssignment $assignment)
{
$this->assignment = $assignment;
$this->dateFormat = static::DEFAULT_DATE_FORMAT;
$this->timeFormat = static::DEFAULT_TIME_FORMAT;
$this->startOfWeekFormat = static::DEFAULT_START_OF_WEEK_FORMAT;
}
public function getId(): ?int
{
return $this->id;
}
public function getAssignment(): UserOrganizationAssignment
{
return $this->assignment;
}
public function getDateFormat(): string
{
return $this->dateFormat;
}
public function setDateFormat(string $dateFormat): self
{
$this->dateFormat = $dateFormat;
return $this;
}
public function getTimeFormat(): string
{
return $this->timeFormat;
}
public function setTimeFormat(string $format): self
{
$this->timeFormat = $format;
return $this;
}
public function getStartOfWeekFormat(): Enum\StartOfWeekFormatSetting
{
return match ($this->startOfWeekFormat)
{
Column\UserOrganizationSettingsStartOfWeekFormat::SUNDAY => Enum\StartOfWeekFormatSetting::SUNDAY(),
Column\UserOrganizationSettingsStartOfWeekFormat::MONDAY => Enum\StartOfWeekFormatSetting::MONDAY(),
default => throw new \RuntimeException('Invalid start of week format'),
};
}
public function setStartOfWeekFormat(Enum\StartOfWeekFormatSetting $format): self
{
$this->startOfWeekFormat = match ($format->getValue())
{
Enum\StartOfWeekFormatSetting::SUNDAY => Column\UserOrganizationSettingsStartOfWeekFormat::SUNDAY,
Enum\StartOfWeekFormatSetting::MONDAY => Column\UserOrganizationSettingsStartOfWeekFormat::MONDAY,
};
return $this;
}
public function isNotifyWeeklyStatsEnabled(): bool
{
return $this->notifyWeeklyStats;
}
public function setNotifyWeeklyStatsEnabled(bool $notifyWeeklyStats): self
{
$this->notifyWeeklyStats = $notifyWeeklyStats;
return $this;
}
public function isNotifySocialEssentialsEnabled(): bool
{
return $this->notifySocialEssentials;
}
public function setNotifySocialEssentialsEnabled(bool $notifySocialEssentials): self
{
$this->notifySocialEssentials = $notifySocialEssentials;
return $this;
}
public function isNotifyQueueEmptyEnabled(): bool
{
return $this->notifyQueueEmpty;
}
public function setNotifyQueueEmptyEnabled(bool $notifyQueueEmpty): self
{
$this->notifyQueueEmpty = $notifyQueueEmpty;
return $this;
}
public function isNotifyPostProfileErrorEnabled(): bool
{
return $this->notifyPostProfileError;
}
public function setNotifyPostProfileErrorEnabled(bool $notifyPostProfileError): self
{
$this->notifyPostProfileError = $notifyPostProfileError;
return $this;
}
public function isNotifyInstagramPostEnabled(): bool
{
return $this->notifyInstagramPost;
}
public function setNotifyInstagramPostEnabled(bool $notifyInstagramPost): self
{
$this->notifyInstagramPost = $notifyInstagramPost;
return $this;
}
public function isNotifyAutoRssEnabled(): bool
{
return $this->notifyAutoRss;
}
public function setNotifyAutoRssEnabled(bool $notifyAutoRss): self
{
$this->notifyAutoRss = $notifyAutoRss;
return $this;
}
}