<?php

namespace App\Entity;

use App\Repository\ProtectionSanitaireRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\Ignore;

/**
 * @ORM\Entity(repositoryClass=ProtectionSanitaireRepository::class)
 * @ORM\Table(schema="sav")
 */
class ProtectionSanitaire
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({"api"})
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=30, nullable=true)
     * @Groups({"api"})
     */
    private $libelle;

    /**
     * @ORM\OneToMany(targetEntity=EquipementInstallation::class, mappedBy="protection_sanitaire")
     * @Ignore()
     */
    private $equipementInstallations;

    public function __construct()
    {
        $this->equipementInstallations = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getLibelle(): ?string
    {
        return $this->libelle;
    }

    public function setLibelle(?string $libelle): self
    {
        $this->libelle = $libelle;

        return $this;
    }

    /**
     * @return Collection<int, EquipementInstallation>
     */
    public function getEquipementInstallations(): Collection
    {
        return $this->equipementInstallations;
    }

    public function addEquipementInstallation(EquipementInstallation $equipementInstallation): self
    {
        if (!$this->equipementInstallations->contains($equipementInstallation)) {
            $this->equipementInstallations[] = $equipementInstallation;
            $equipementInstallation->setProtectionSanitaire($this);
        }

        return $this;
    }

    public function removeEquipementInstallation(EquipementInstallation $equipementInstallation): self
    {
        if ($this->equipementInstallations->removeElement($equipementInstallation)) {
            // set the owning side to null (unless already changed)
            if ($equipementInstallation->getProtectionSanitaire() === $this) {
                $equipementInstallation->setProtectionSanitaire(null);
            }
        }

        return $this;
    }
}
