<?php

namespace App\Entity;

use App\Repository\OptionRepository;
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=OptionRepository::class)
 * @ORM\Table(schema="sav")
 */
class Option
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({"api", "site_list"})
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=30, nullable=true)
     * @Groups({"api", "site_list"})
     */
    private $libelle_court;

    /**
     * @ORM\Column(type="string", length=100, nullable=true)
     * @Groups({"api", "site_list"})
     */
    private $libelle_long;

    /**
     * @ORM\OneToMany(targetEntity=EquipementTypeOption::class, mappedBy="option",  orphanRemoval=true)
     * @Ignore()
     */
    private $equipementTypeOptions;

    /**
     * @ORM\OneToMany(targetEntity=OptionTarif::class, mappedBy="option",  orphanRemoval=true)
     */
    private $optionTarifs;

    /**
     * @ORM\OneToMany(targetEntity=EquipementOption::class, mappedBy="option", orphanRemoval=true)
     * @Ignore()
     */
    private $equipementOptions;

    /**
     * @ORM\Column(type="boolean", nullable=true)
     * @Groups({"api"})
     */
    private $upec;


    public function __construct()
    {
        $this->equipementTypeOptions = new ArrayCollection();
        $this->optionTarifs = new ArrayCollection();
        $this->equipementOptions = 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;
    }

    /**
     * @return Collection|EquipementTypeOption[]
     */
    public function getEquipementTypeOptions(): Collection
    {
        return $this->equipementTypeOptions;
    }

    public function addEquipementTypeOption(EquipementTypeOption $equipementTypeOption): self
    {
        if (!$this->equipementTypeOptions->contains($equipementTypeOption)) {
            $this->equipementTypeOptions[] = $equipementTypeOption;
            $equipementTypeOption->setOption($this);
        }

        return $this;
    }

    public function removeEquipementTypeOption(EquipementTypeOption $equipementTypeOption): self
    {
        if ($this->equipementTypeOptions->removeElement($equipementTypeOption)) {
            // set the owning side to null (unless already changed)
            if ($equipementTypeOption->getOption() === $this) {
                $equipementTypeOption->setOption(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->setOption($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->getOption() === $this) {
                $optionTarif->setOption(null);
            }
        }

        return $this;
    }

    public function __toString()
    {
       return $this->getLibelleCourt();
    }

    /**
     * @return Collection|EquipementOption[]
     */
    public function getEquipementOptions(): Collection
    {
        return $this->equipementOptions;
    }

    public function addEquipementOption(EquipementOption $equipementOption): self
    {
        if (!$this->equipementOptions->contains($equipementOption)) {
            $this->equipementOptions[] = $equipementOption;
            $equipementOption->setOption($this);
        }

        return $this;
    }

    public function removeEquipementOption(EquipementOption $equipementOption): self
    {
        if ($this->equipementOptions->removeElement($equipementOption)) {
            // set the owning side to null (unless already changed)
            if ($equipementOption->getOption() === $this) {
                $equipementOption->setOption(null);
            }
        }

        return $this;
    }

    public function getUpec(): ?bool
    {
        return $this->upec;
    }

    public function setUpec(?bool $upec): self
    {
        $this->upec = $upec;

        return $this;
    }
}
