<?phpdeclare(strict_types=1);namespace App\Infrastructure\Doctrine\Entity;use App\Domain\Common\Entity\ColorFamily;use App\Domain\Common\Entity\IzOrderColor;use App\Domain\Common\Entity\IzOrderProduct;use App\Infrastructure\Doctrine\Entity\Traits\IdableTrait;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use function Symfony\Component\String\u;/** * @ORM\Entity(repositoryClass="App\Infrastructure\Doctrine\Repository\DoctrineIzOrderColorRepository") */class DoctrineIzOrderColor implements IzOrderColor{ use IdableTrait; /** * @ORM\Column(type="string", length=191) */ private string $importCode = ''; /** * @ORM\Column(type="string", length=191) */ private string $importLabel = ''; /** * @ORM\Column(type="json", nullable=true) */ private array $hexadecimalCodes = []; /** * @ORM\Column(type="string", length=191, nullable=true) */ private ?string $label = null; /** * @var Collection<int, ColorFamily> * * @ORM\ManyToMany(targetEntity="App\Infrastructure\Doctrine\Entity\DoctrineColorFamily", mappedBy="colors") */ private iterable $families; /** * @var Collection<int, IzOrderProduct> * * @ORM\OneToMany(targetEntity="App\Infrastructure\Doctrine\Entity\DoctrineIzOrderProduct", mappedBy="codeCouleur") */ private iterable $products; public function __construct() { $this->families = new ArrayCollection(); $this->products = new ArrayCollection(); } public function __toString(): string { return $this->getLabel(); } public function getImportCode(): string { return $this->importCode; } public function setImportCode(string $importCode): void { $this->importCode = $importCode; $this->setImportLabel((string) u($importCode)->lower()->title()); } public function getImportLabel(): string { return $this->importLabel; } public function setImportLabel(string $importLabel): void { $this->importLabel = $importLabel; } public function getHexadecimalCodes(): array { return $this->hexadecimalCodes ?: []; } public function setHexadecimalCodes(array $hexadecimalCodes): void { $this->hexadecimalCodes = $hexadecimalCodes; } public function getLabel(): string { return $this->label ?: $this->getImportLabel(); } public function setLabel(?string $label): void { $this->label = $label; } /** * {@inheritDoc} */ public function getFamilies(): iterable { return $this->families; } public function addFamily(ColorFamily $family): self { if (!$this->families->contains($family)) { $this->families[] = $family; $family->addColor($this); } return $this; } public function removeFamily(ColorFamily $family): self { if ($this->families->removeElement($family)) { $family->removeColor($this); } return $this; } /** * {@inheritDoc} */ public function getProducts(): iterable { return $this->products; } public function addProduct(IzOrderProduct $product): void { if (!$this->products->contains($product)) { $this->products[] = $product; $product->setCodeCouleur($this); } } public function removeProduct(IzOrderProduct $product): void { if ($this->products->removeElement($product) && $product->getCodeCouleur() === $this) { $product->setCodeCouleur(null); } }}