<?php
namespace App\Entity\System;
use App\Util\Temporal;
use Doctrine\ORM\Mapping as ORM;
use Reinder83\BinaryFlags\Bits;
/**
* @ORM\Embeddable()
*/
class SchoolBrandingEmbeddable
{
const IMAGES = [
'logo__primary' => self::IMAGES__LOGO__PRIMARY,
'logo__secondary' => self::IMAGES__LOGO__SECONDARY,
'mobile__splash_background' => self::IMAGES__MOBILE__SPLASH_BACKGROUND,
'mobile__splash_overlay' => self::IMAGES__MOBILE__SPLASH_OVERLAY,
'mobile__marketing' => self::IMAGES__MOBILE__MARKETING,
'building' => self::IMAGES__BUILDING,
'email__header_logo' => self::IMAGES__EMAIL__HEADER_LOGO,
];
const IMAGES__LOGO__PRIMARY = Bits::BIT_1;
const IMAGES__LOGO__SECONDARY = Bits::BIT_2;
const IMAGES__MOBILE__SPLASH_BACKGROUND = Bits::BIT_3;
const IMAGES__MOBILE__SPLASH_OVERLAY = Bits::BIT_4;
const IMAGES__MOBILE__MARKETING = Bits::BIT_5;
const IMAGES__BUILDING = Bits::BIT_6;
const IMAGES__EMAIL__HEADER_LOGO = Bits::BIT_7;
/**
* @var int
*
* @ORM\Column(
* type = "bigint",
* nullable = false,
* options = {
* "default" = 0,
* },
* )
*/
protected int $bust = 0;
/**
* @var int
*
* @ORM\Column(
* type = "bigint",
* nullable = false,
* options = {
* "default" = 0,
* },
* )
*/
protected int $images = 0;
/**
* @var string|null
*
* @ORM\Column(
* type = "string",
* nullable = true,
* length = 6,
* )
*/
protected ?string $colorPrimary = null;
/**
* @var string|null
*
* @ORM\Column(
* type = "string",
* nullable = true,
* length = 6,
* )
*/
protected ?string $colorSecondary = null;
/**
* @var string|null
*
* @ORM\Column(
* type = "string",
* nullable = true,
* length = 6,
* )
*/
protected ?string $colorTertiary = null;
/**
* @var string|null
*
* @ORM\Column(
* type = "string",
* nullable = true,
* length = 6,
* )
*/
protected ?string $colorMobileHeader = null;
/**
* @var string|null
*
* @ORM\Column(
* type = "string",
* nullable = true,
* length = 6,
* )
*/
protected ?string $colorMobileText = null;
/**
* @return int
*/
public function getImages(): int
{
return $this->images;
}
/**
* @param int|null $images
* @return $this
*/
public function setImages(?int $images): self
{
$this->images = $images ?: 0;
$this->bust = Temporal::unixMilliseconds();
return $this;
}
/**
* @param int $image
* @return bool
*/
public function hasImage(int $image): bool
{
return (($this->images & $image) > 0);
}
/**
* @param int $image
* @return $this
*/
public function setImage(int $image): self
{
$this->images |= $image;
$this->bust = Temporal::unixMilliseconds();
return $this;
}
/**
* @param int $image
* @return $this
*/
public function unsetImage(int $image): self
{
$this->images &= (~$image);
$this->bust = Temporal::unixMilliseconds();
return $this;
}
/**
* @param int $image
* @param bool|null $toggle
* @return $this
*/
public function toggleImage(int $image, ?bool $toggle = null): self
{
if ($toggle === null) {
$toggle = $this->hasImage($image);
}
return ($toggle) ? $this->unsetImage($image) : $this->setImage($image);
}
/**
* @return string|null
*/
public function getColorPrimary(): ?string
{
return $this->colorPrimary;
}
/**
* @param string|null $colorPrimary
* @return $this
*/
public function setColorPrimary(?string $colorPrimary): self
{
$this->colorPrimary = $colorPrimary;
return $this;
}
/**
* @return string|null
*/
public function getColorSecondary(): ?string
{
return $this->colorSecondary;
}
/**
* @param string|null $colorSecondary
* @return $this
*/
public function setColorSecondary(?string $colorSecondary): self
{
$this->colorSecondary = $colorSecondary;
return $this;
}
/**
* @return string|null
*/
public function getColorTertiary(): ?string
{
return $this->colorTertiary;
}
/**
* @param string|null $colorTertiary
* @return $this
*/
public function setColorTertiary(?string $colorTertiary): self
{
$this->colorTertiary = $colorTertiary;
return $this;
}
/**
* @return string|null
*/
public function getColorMobileHeader(): ?string
{
return $this->colorMobileHeader;
}
/**
* @param string|null $colorMobileHeader
* @return $this
*/
public function setColorMobileHeader(?string $colorMobileHeader): self
{
$this->colorMobileHeader = $colorMobileHeader;
return $this;
}
/**
* @return string|null
*/
public function getColorMobileText(): ?string
{
return $this->colorMobileText;
}
/**
* @param string|null $colorMobileText
* @return $this
*/
public function setColorMobileText(?string $colorMobileText): self
{
$this->colorMobileText = $colorMobileText;
return $this;
}
/**
* @return string
*/
public function getBust(): ?string
{
return $this->bust ? strval($this->bust) : null;
}
}