app/Entity/Schema/ORM/UserOrganizationSettings.php line 11

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Sq\Entity\Schema\ORM;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Sq\Entity\Enum;
  5. use Sq\Entity\Schema\Column;
  6. #[ORM\Entity]
  7. #[ORM\Table(name'user_organization_settings')]
  8. class UserOrganizationSettings
  9. {
  10.     protected const DEFAULT_DATE_FORMAT Enum\DateFormatSetting::DAY_MONTH_YEAR;
  11.     protected const DEFAULT_TIME_FORMAT Enum\TimeFormatSetting::HOUR_24;
  12.     protected const DEFAULT_START_OF_WEEK_FORMAT Enum\StartOfWeekFormatSetting::SUNDAY;
  13.     /**
  14.      *
  15.      * @var int|null
  16.      */
  17.     #[ORM\Id]
  18.     #[ORM\Column(name'uos_id'type'integer'nullablefalseoptions: ['unsigned' => true])]
  19.     #[ORM\GeneratedValue(strategy'AUTO')]
  20.     private $id;
  21.     /**
  22.      *
  23.      * @var UserOrganizationAssignment
  24.      */
  25.     #[ORM\OneToOne(targetEntityUserOrganizationAssignment::class, inversedBy'settings'cascade: ['persist'])]
  26.     #[ORM\JoinColumn(name'uos_uoa_id'referencedColumnName'uoa_id'nullablefalse)]
  27.     private $assignment;
  28.     /**
  29.      * @var string
  30.      */
  31.     #[ORM\Column(name'uos_date_format'type'string'length191nullablefalse)]
  32.     private $dateFormat;
  33.     /**
  34.      * @var string
  35.      */
  36.     #[ORM\Column(name'uos_time_format'type'string'length191nullablefalse)]
  37.     private $timeFormat;
  38.     /**
  39.      * @var string
  40.      */
  41.     #[ORM\Column(name'uos_start_of_week_format'type'string'length191nullablefalse)]
  42.     private $startOfWeekFormat;
  43.     /**
  44.      * @var bool
  45.      */
  46.     #[ORM\Column(name'uos_notify_weekly_stats'type'boolean'nullablefalseoptions: ['default' => true])]
  47.     private $notifyWeeklyStats true;
  48.     /**
  49.      * @var bool
  50.      */
  51.     #[ORM\Column(name'uos_notify_queue_empty'type'boolean'nullablefalseoptions: ['default' => true])]
  52.     private $notifyQueueEmpty true;
  53.     /**
  54.      * @var bool
  55.      */
  56.     #[ORM\Column(name'uos_notify_post_profile_error'type'boolean'nullablefalseoptions: ['default' => true])]
  57.     private $notifyPostProfileError true;
  58.     /**
  59.      * @var bool
  60.      */
  61.     #[ORM\Column(name'uos_notify_instagram_post'type'boolean'nullablefalseoptions: ['default' => false])]
  62.     private $notifyInstagramPost false;
  63.     /**
  64.      * @var bool
  65.      */
  66.     #[ORM\Column(name'uos_notify_auto_rss'type'boolean'nullablefalseoptions: ['default' => true])]
  67.     private $notifyAutoRss true;
  68.     /**
  69.      * @var bool
  70.      */
  71.     #[ORM\Column(name'uos_notify_social_essentials'type'boolean'nullablefalseoptions: ['default' => true])]
  72.     private bool $notifySocialEssentials true;
  73.     public function __construct(UserOrganizationAssignment $assignment)
  74.     {
  75.         $this->assignment $assignment;
  76.         $this->dateFormat = static::DEFAULT_DATE_FORMAT;
  77.         $this->timeFormat = static::DEFAULT_TIME_FORMAT;
  78.         $this->startOfWeekFormat = static::DEFAULT_START_OF_WEEK_FORMAT;
  79.     }
  80.     public function getId(): ?int
  81.     {
  82.         return $this->id;
  83.     }
  84.     public function getAssignment(): UserOrganizationAssignment
  85.     {
  86.         return $this->assignment;
  87.     }
  88.     public function getDateFormat(): string
  89.     {
  90.         return $this->dateFormat;
  91.     }
  92.     public function setDateFormat(string $dateFormat): self
  93.     {
  94.         $this->dateFormat $dateFormat;
  95.         return $this;
  96.     }
  97.     public function getTimeFormat(): string
  98.     {
  99.         return $this->timeFormat;
  100.     }
  101.     public function setTimeFormat(string $format): self
  102.     {
  103.         $this->timeFormat $format;
  104.         return $this;
  105.     }
  106.     public function getStartOfWeekFormat(): Enum\StartOfWeekFormatSetting
  107.     {
  108.         return match ($this->startOfWeekFormat)
  109.         {
  110.             Column\UserOrganizationSettingsStartOfWeekFormat::SUNDAY => Enum\StartOfWeekFormatSetting::SUNDAY(),
  111.             Column\UserOrganizationSettingsStartOfWeekFormat::MONDAY => Enum\StartOfWeekFormatSetting::MONDAY(),
  112.             default => throw new \RuntimeException('Invalid start of week format'),
  113.         };
  114.     }
  115.     public function setStartOfWeekFormat(Enum\StartOfWeekFormatSetting $format): self
  116.     {
  117.         $this->startOfWeekFormat = match ($format->getValue())
  118.         {
  119.             Enum\StartOfWeekFormatSetting::SUNDAY => Column\UserOrganizationSettingsStartOfWeekFormat::SUNDAY,
  120.             Enum\StartOfWeekFormatSetting::MONDAY => Column\UserOrganizationSettingsStartOfWeekFormat::MONDAY,
  121.         };
  122.         return $this;
  123.     }
  124.     public function isNotifyWeeklyStatsEnabled(): bool
  125.     {
  126.         return $this->notifyWeeklyStats;
  127.     }
  128.     public function setNotifyWeeklyStatsEnabled(bool $notifyWeeklyStats): self
  129.     {
  130.         $this->notifyWeeklyStats $notifyWeeklyStats;
  131.         return $this;
  132.     }
  133.     public function isNotifySocialEssentialsEnabled(): bool
  134.     {
  135.         return $this->notifySocialEssentials;
  136.     }
  137.     public function setNotifySocialEssentialsEnabled(bool $notifySocialEssentials): self
  138.     {
  139.         $this->notifySocialEssentials $notifySocialEssentials;
  140.         return $this;
  141.     }
  142.     public function isNotifyQueueEmptyEnabled(): bool
  143.     {
  144.         return $this->notifyQueueEmpty;
  145.     }
  146.     public function setNotifyQueueEmptyEnabled(bool $notifyQueueEmpty): self
  147.     {
  148.         $this->notifyQueueEmpty $notifyQueueEmpty;
  149.         return $this;
  150.     }
  151.     public function isNotifyPostProfileErrorEnabled(): bool
  152.     {
  153.         return $this->notifyPostProfileError;
  154.     }
  155.     public function setNotifyPostProfileErrorEnabled(bool $notifyPostProfileError): self
  156.     {
  157.         $this->notifyPostProfileError $notifyPostProfileError;
  158.         return $this;
  159.     }
  160.     public function isNotifyInstagramPostEnabled(): bool
  161.     {
  162.         return $this->notifyInstagramPost;
  163.     }
  164.     public function setNotifyInstagramPostEnabled(bool $notifyInstagramPost): self
  165.     {
  166.         $this->notifyInstagramPost $notifyInstagramPost;
  167.         return $this;
  168.     }
  169.     public function isNotifyAutoRssEnabled(): bool
  170.     {
  171.         return $this->notifyAutoRss;
  172.     }
  173.     public function setNotifyAutoRssEnabled(bool $notifyAutoRss): self
  174.     {
  175.         $this->notifyAutoRss $notifyAutoRss;
  176.         return $this;
  177.     }
  178. }