<?php

namespace App\Entity;

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

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

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

    /**
     * @ORM\OneToMany(targetEntity=Intervention::class, mappedBy="type_envoi_rapport")
     * @Ignore()
     */
    private $interventions;

    /**
     * @ORM\OneToMany(targetEntity=ContratResiliation::class, mappedBy="type_envoi")
     */
    private $contratResiliations;

    /**
     * @ORM\OneToMany(targetEntity=Devis::class, mappedBy="type_envoi")
     */
    private $devis;

    public function __construct()
    {
        $this->interventions = new ArrayCollection();
        $this->contratResiliations = new ArrayCollection();
        $this->devis = new ArrayCollection();
    }

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

    public function setId(?int $id): self
    {
        $this->id = $id;

        return $this;
    }

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

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

        return $this;
    }

    /**
     * @return Collection<int, Intervention>
     */
    public function getInterventions(): Collection
    {
        return $this->interventions;
    }

    public function addIntervention(Intervention $intervention): self
    {
        if (!$this->interventions->contains($intervention)) {
            $this->interventions[] = $intervention;
            $intervention->setTypeEnvoiRapport($this);
        }

        return $this;
    }

    public function removeIntervention(Intervention $intervention): self
    {
        if ($this->interventions->removeElement($intervention)) {
            // set the owning side to null (unless already changed)
            if ($intervention->getTypeEnvoiRapport() === $this) {
                $intervention->setTypeEnvoiRapport(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, ContratResiliation>
     */
    public function getContratResiliations(): Collection
    {
        return $this->contratResiliations;
    }

    public function addContratResiliation(ContratResiliation $contratResiliation): self
    {
        if (!$this->contratResiliations->contains($contratResiliation)) {
            $this->contratResiliations[] = $contratResiliation;
            $contratResiliation->setTypeEnvoi($this);
        }

        return $this;
    }

    public function removeContratResiliation(ContratResiliation $contratResiliation): self
    {
        if ($this->contratResiliations->removeElement($contratResiliation)) {
            // set the owning side to null (unless already changed)
            if ($contratResiliation->getTypeEnvoi() === $this) {
                $contratResiliation->setTypeEnvoi(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Devis>
     */
    public function getDevis(): Collection
    {
        return $this->devis;
    }

    public function addDevi(Devis $devi): self
    {
        if (!$this->devis->contains($devi)) {
            $this->devis[] = $devi;
            $devi->setTypeEnvoi($this);
        }

        return $this;
    }

    public function removeDevi(Devis $devi): self
    {
        if ($this->devis->removeElement($devi)) {
            // set the owning side to null (unless already changed)
            if ($devi->getTypeEnvoi() === $this) {
                $devi->setTypeEnvoi(null);
            }
        }

        return $this;
    }
}
