<?php
declare(strict_types=1);
namespace App\Infrastructure\Doctrine\Entity;
use App\Domain\Common\Entity\ColorFamily;
use App\Domain\Common\Entity\IzOrderColor;
use App\Infrastructure\Doctrine\Entity\Traits\IdableTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Infrastructure\Doctrine\Repository\DoctrineColorFamilyRepository")
*/
class DoctrineColorFamily implements ColorFamily
{
use IdableTrait;
/**
* @ORM\Column(type="string", length=191)
*/
private string $label = '';
/**
* @ORM\Column(type="string", length=191, nullable=true)
*/
private ?string $hexadecimalCode = null;
/**
* @var Collection<int, IzOrderColor>
*
* @ORM\ManyToMany(targetEntity="App\Infrastructure\Doctrine\Entity\DoctrineIzOrderColor", inversedBy="families")
* @ORM\JoinTable(name="x_color_family",
* joinColumns={@ORM\JoinColumn(name="family_id", referencedColumnName="id", nullable=false)},
* inverseJoinColumns={@ORM\JoinColumn(name="color_id", referencedColumnName="id", nullable=false)},
* )
*/
private iterable $colors;
public function __construct()
{
$this->colors = new ArrayCollection();
}
public function __toString(): string
{
return $this->getLabel();
}
public function getLabel(): string
{
return $this->label;
}
public function setLabel(string $label): void
{
$this->label = $label;
}
public function getHexadecimalCode(): ?string
{
return $this->hexadecimalCode;
}
public function setHexadecimalCode(?string $hexadecimalCode): void
{
$this->hexadecimalCode = $hexadecimalCode;
}
/**
* {@inheritDoc}
*/
public function getColors(): iterable
{
return $this->colors;
}
public function addColor(IzOrderColor $color): void
{
if (!$this->colors->contains($color)) {
$this->colors[] = $color;
}
}
public function removeColor(IzOrderColor $color): void
{
$this->colors->removeElement($color);
}
}