src/App/Entity/System/SchoolBrandingEmbeddable.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use App\Util\Temporal;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Reinder83\BinaryFlags\Bits;
  6. /**
  7.  * @ORM\Embeddable()
  8.  */
  9. class SchoolBrandingEmbeddable
  10. {
  11.     const IMAGES = [
  12.         'logo__primary' => self::IMAGES__LOGO__PRIMARY,
  13.         'logo__secondary' => self::IMAGES__LOGO__SECONDARY,
  14.         'mobile__splash_background' => self::IMAGES__MOBILE__SPLASH_BACKGROUND,
  15.         'mobile__splash_overlay' => self::IMAGES__MOBILE__SPLASH_OVERLAY,
  16.         'mobile__marketing' => self::IMAGES__MOBILE__MARKETING,
  17.         'building' => self::IMAGES__BUILDING,
  18.         'email__header_logo' => self::IMAGES__EMAIL__HEADER_LOGO,
  19.     ];
  20.     const IMAGES__LOGO__PRIMARY Bits::BIT_1;
  21.     const IMAGES__LOGO__SECONDARY Bits::BIT_2;
  22.     const IMAGES__MOBILE__SPLASH_BACKGROUND Bits::BIT_3;
  23.     const IMAGES__MOBILE__SPLASH_OVERLAY Bits::BIT_4;
  24.     const IMAGES__MOBILE__MARKETING Bits::BIT_5;
  25.     const IMAGES__BUILDING Bits::BIT_6;
  26.     const IMAGES__EMAIL__HEADER_LOGO Bits::BIT_7;
  27.     /**
  28.      * @var int
  29.      *
  30.      * @ORM\Column(
  31.      *     type = "bigint",
  32.      *     nullable = false,
  33.      *     options = {
  34.      *         "default" = 0,
  35.      *     },
  36.      * )
  37.      */
  38.     protected int $bust 0;
  39.     /**
  40.      * @var int
  41.      *
  42.      * @ORM\Column(
  43.      *     type = "bigint",
  44.      *     nullable = false,
  45.      *     options = {
  46.      *         "default" = 0,
  47.      *     },
  48.      * )
  49.      */
  50.     protected int $images 0;
  51.     /**
  52.      * @var string|null
  53.      *
  54.      * @ORM\Column(
  55.      *     type = "string",
  56.      *     nullable = true,
  57.      *     length = 6,
  58.      * )
  59.      */
  60.     protected ?string $colorPrimary null;
  61.     /**
  62.      * @var string|null
  63.      *
  64.      * @ORM\Column(
  65.      *     type = "string",
  66.      *     nullable = true,
  67.      *     length = 6,
  68.      * )
  69.      */
  70.     protected ?string $colorSecondary null;
  71.     /**
  72.      * @var string|null
  73.      *
  74.      * @ORM\Column(
  75.      *     type = "string",
  76.      *     nullable = true,
  77.      *     length = 6,
  78.      * )
  79.      */
  80.     protected ?string $colorTertiary null;
  81.     /**
  82.      * @var string|null
  83.      *
  84.      * @ORM\Column(
  85.      *     type = "string",
  86.      *     nullable = true,
  87.      *     length = 6,
  88.      * )
  89.      */
  90.     protected ?string $colorMobileHeader null;
  91.     /**
  92.      * @var string|null
  93.      *
  94.      * @ORM\Column(
  95.      *     type = "string",
  96.      *     nullable = true,
  97.      *     length = 6,
  98.      * )
  99.      */
  100.     protected ?string $colorMobileText null;
  101.     /**
  102.      * @return int
  103.      */
  104.     public function getImages(): int
  105.     {
  106.         return $this->images;
  107.     }
  108.     /**
  109.      * @param int|null $images
  110.      * @return $this
  111.      */
  112.     public function setImages(?int $images): self
  113.     {
  114.         $this->images $images ?: 0;
  115.         $this->bust Temporal::unixMilliseconds();
  116.         return $this;
  117.     }
  118.     /**
  119.      * @param int $image
  120.      * @return bool
  121.      */
  122.     public function hasImage(int $image): bool
  123.     {
  124.         return (($this->images $image) > 0);
  125.     }
  126.     /**
  127.      * @param int $image
  128.      * @return $this
  129.      */
  130.     public function setImage(int $image): self
  131.     {
  132.         $this->images |= $image;
  133.         $this->bust Temporal::unixMilliseconds();
  134.         return $this;
  135.     }
  136.     /**
  137.      * @param int $image
  138.      * @return $this
  139.      */
  140.     public function unsetImage(int $image): self
  141.     {
  142.         $this->images &= (~$image);
  143.         $this->bust Temporal::unixMilliseconds();
  144.         return $this;
  145.     }
  146.     /**
  147.      * @param int $image
  148.      * @param bool|null $toggle
  149.      * @return $this
  150.      */
  151.     public function toggleImage(int $image, ?bool $toggle null): self
  152.     {
  153.         if ($toggle === null) {
  154.             $toggle $this->hasImage($image);
  155.         }
  156.         return ($toggle) ? $this->unsetImage($image) : $this->setImage($image);
  157.     }
  158.     /**
  159.      * @return string|null
  160.      */
  161.     public function getColorPrimary(): ?string
  162.     {
  163.         return $this->colorPrimary;
  164.     }
  165.     /**
  166.      * @param string|null $colorPrimary
  167.      * @return $this
  168.      */
  169.     public function setColorPrimary(?string $colorPrimary): self
  170.     {
  171.         $this->colorPrimary $colorPrimary;
  172.         return $this;
  173.     }
  174.     /**
  175.      * @return string|null
  176.      */
  177.     public function getColorSecondary(): ?string
  178.     {
  179.         return $this->colorSecondary;
  180.     }
  181.     /**
  182.      * @param string|null $colorSecondary
  183.      * @return $this
  184.      */
  185.     public function setColorSecondary(?string $colorSecondary): self
  186.     {
  187.         $this->colorSecondary $colorSecondary;
  188.         return $this;
  189.     }
  190.     /**
  191.      * @return string|null
  192.      */
  193.     public function getColorTertiary(): ?string
  194.     {
  195.         return $this->colorTertiary;
  196.     }
  197.     /**
  198.      * @param string|null $colorTertiary
  199.      * @return $this
  200.      */
  201.     public function setColorTertiary(?string $colorTertiary): self
  202.     {
  203.         $this->colorTertiary $colorTertiary;
  204.         return $this;
  205.     }
  206.     /**
  207.      * @return string|null
  208.      */
  209.     public function getColorMobileHeader(): ?string
  210.     {
  211.         return $this->colorMobileHeader;
  212.     }
  213.     /**
  214.      * @param string|null $colorMobileHeader
  215.      * @return $this
  216.      */
  217.     public function setColorMobileHeader(?string $colorMobileHeader): self
  218.     {
  219.         $this->colorMobileHeader $colorMobileHeader;
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return string|null
  224.      */
  225.     public function getColorMobileText(): ?string
  226.     {
  227.         return $this->colorMobileText;
  228.     }
  229.     /**
  230.      * @param string|null $colorMobileText
  231.      * @return $this
  232.      */
  233.     public function setColorMobileText(?string $colorMobileText): self
  234.     {
  235.         $this->colorMobileText $colorMobileText;
  236.         return $this;
  237.     }
  238.     /**
  239.      * @return string
  240.      */
  241.     public function getBust(): ?string
  242.     {
  243.         return $this->bust strval($this->bust) : null;
  244.     }
  245. }