<?php

namespace App\Entity;

use App\Repository\ContratTypeRepository;
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=ContratTypeRepository::class)
 * @ORM\Table(schema="sav")
 */
class ContratType
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({"api", "planning"})
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=8, nullable=true)
     * @Groups({"api", "map", "planning"})
     */
    private $libelle_court;

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

    /**
     * @ORM\ManyToOne(targetEntity=ContratRegroupement::class, inversedBy="contratTypes")
     * @ORM\JoinColumn(name="idcontrat_regroupement")
     */
    private $contrat_regroupement;

    /**
     * @ORM\OneToMany(targetEntity=ContratTarif::class, mappedBy="contrat_type")
     * @Ignore()
     */
    private $contratTarifs;

    /**
     * @ORM\OneToMany(targetEntity=OptionTarif::class, mappedBy="ContratType")
     * @Ignore()
     */
    private $optionTarifs;

    /**
     * @ORM\OneToMany(targetEntity=Contrat::class, mappedBy="contrat_type")
     * @Ignore()
     */
    private $contrats;

    public function __construct()
    {
        $this->optionTarifs = new ArrayCollection();
        $this->contratTarifs = new ArrayCollection();
        $this->contrats = new ArrayCollection();
    }

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

    public function getLibelleCourt(): ?string
    {
        return $this->libelle_court;
    }

    public function setLibelleCourt(?string $libelle_court): self
    {
        $this->libelle_court = $libelle_court;

        return $this;
    }

    public function getLibelleLong(): ?string
    {
        return $this->libelle_long;
    }

    public function setLibelleLong(?string $libelle_long): self
    {
        $this->libelle_long = $libelle_long;

        return $this;
    }

    public function getContratRegroupement(): ?ContratRegroupement
    {
        return $this->contrat_regroupement;
    }

    public function setContratRegroupement(?ContratRegroupement $contrat_regroupement): self
    {
        $this->contrat_regroupement = $contrat_regroupement;

        return $this;
    }

    /**
     * @return Collection|ContratTarif[]
     */
    public function getContratTarifs(): Collection
    {
        return $this->contratTarifs;
    }

    public function addContratTarif(ContratTarif $contratTarif): self
    {
        if (!$this->contratTarifs->contains($contratTarif)) {
            $this->contratTarifs[] = $contratTarif;
            $contratTarif->setContratType($this);
        }

        return $this;
    }

    public function removeContratTarif(ContratTarif $contratTarif): self
    {
        if ($this->contratTarifs->removeElement($contratTarif)) {
            // set the owning side to null (unless already changed)
            if ($contratTarif->getContratType() === $this) {
                $contratTarif->setContratType(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|OptionTarif[]
     */
    public function getOptionTarifs(): Collection
    {
        return $this->optionTarifs;
    }

    public function addOptionTarif(OptionTarif $optionTarif): self
    {
        if (!$this->optionTarifs->contains($optionTarif)) {
            $this->optionTarifs[] = $optionTarif;
            $optionTarif->setContratType($this);
        }

        return $this;
    }

    public function removeOptionTarif(OptionTarif $optionTarif): self
    {
        if ($this->optionTarifs->removeElement($optionTarif)) {
            // set the owning side to null (unless already changed)
            if ($optionTarif->getContratType() === $this) {
                $optionTarif->setContratType(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Contrat>
     */
    public function getContrats(): Collection
    {
        return $this->contrats;
    }

    public function addContrat(Contrat $contrat): self
    {
        if (!$this->contrats->contains($contrat)) {
            $this->contrats[] = $contrat;
            $contrat->setContratType($this);
        }

        return $this;
    }

    public function removeContrat(Contrat $contrat): self
    {
        if ($this->contrats->removeElement($contrat)) {
            // set the owning side to null (unless already changed)
            if ($contrat->getContratType() === $this) {
                $contrat->setContratType(null);
            }
        }

        return $this;
    }
}
