src/Infrastructure/Doctrine/Entity/DoctrineIzOrderProductRange.php line 16

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Infrastructure\Doctrine\Entity;
  4. use App\Domain\Common\Entity\IzOrderProduct;
  5. use App\Domain\Common\Entity\IzOrderProductRange;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Infrastructure\Doctrine\Repository\DoctrineIzOrderProductRangeRepository")
  11.  */
  12. class DoctrineIzOrderProductRange implements IzOrderProductRange
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\Column(type="string", length=16, unique=true)
  17.      */
  18.     private string $codeGamme '';
  19.     /**
  20.      * @ORM\Column(type="string", length=191, nullable=true)
  21.      */
  22.     private ?string $nomGamme null;
  23.     /**
  24.      * @var Collection<int, IzOrderProduct>
  25.      *
  26.      * @ORM\OneToMany(targetEntity="App\Infrastructure\Doctrine\Entity\DoctrineIzOrderProduct", mappedBy="codeGamme")
  27.      */
  28.     private iterable $products;
  29.     public function __construct()
  30.     {
  31.         $this->products = new ArrayCollection();
  32.     }
  33.     public function __toString(): string
  34.     {
  35.         return $this->getCodeGamme();
  36.     }
  37.     public function getCodeGamme(): string
  38.     {
  39.         return $this->codeGamme;
  40.     }
  41.     public function setCodeGamme(string $codeGamme): void
  42.     {
  43.         $this->codeGamme $codeGamme;
  44.     }
  45.     public function getNomGamme(): ?string
  46.     {
  47.         return $this->nomGamme;
  48.     }
  49.     public function setNomGamme(?string $nomGamme): void
  50.     {
  51.         $this->nomGamme $nomGamme;
  52.     }
  53.     /**
  54.      * {@inheritDoc}
  55.      */
  56.     public function getProducts(): iterable
  57.     {
  58.         return $this->products;
  59.     }
  60.     public function addProduct(IzOrderProduct $product): void
  61.     {
  62.         if (!$this->products->contains($product)) {
  63.             $this->products[] = $product;
  64.             $product->setCodeGamme($this);
  65.         }
  66.     }
  67.     public function removeProduct(IzOrderProduct $product): void
  68.     {
  69.         if ($this->products->removeElement($product) && $product->getCodeGamme() === $this) {
  70.             $product->setCodeGamme(null);
  71.         }
  72.     }
  73. }