<?php

namespace App\Entity;

use App\Repository\TypeComplementAdresseRepository;
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=TypeComplementAdresseRepository::class)
 * @ORM\Table(schema="sav")
 */
class TypeComplementAdresse
{
    Const ID_BATIMENT = 2;
    Const ID_PORTE = 3;
    Const ID_ETAGE = 4;
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({"api", "site_list"})
     */
    private $id;

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

    /**
     * @ORM\OneToMany(targetEntity=AdresseComplement::class, mappedBy="type_complement_adresse")
     * @Ignore()
     */
    private $adresseComplements;

    public function __construct()
    {
        $this->adresseComplements = 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, AdresseComplement>
     */
    public function getAdresseComplements(): Collection
    {
        return $this->adresseComplements;
    }

    public function addAdresseComplement(AdresseComplement $adresseComplement): self
    {
        if (!$this->adresseComplements->contains($adresseComplement)) {
            $this->adresseComplements[] = $adresseComplement;
            $adresseComplement->setTypeComplementAdresse($this);
        }

        return $this;
    }

    public function removeAdresseComplement(AdresseComplement $adresseComplement): self
    {
        if ($this->adresseComplements->removeElement($adresseComplement)) {
            // set the owning side to null (unless already changed)
            if ($adresseComplement->getTypeComplementAdresse() === $this) {
                $adresseComplement->setTypeComplementAdresse(null);
            }
        }

        return $this;
    }

    public function __toString() {
        return $this->getLibelle();
    }
}
