<?php

namespace App\Entity;

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

/**
 * @ORM\Entity(repositoryClass=TypeDureeRepository::class)
 * @ORM\Table(schema="sav")
 */
class TypeDuree
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({"site_list", "planning"})
     */
    private $id;

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

    /**
     * @ORM\OneToMany(targetEntity=Planning::class, mappedBy="type_duree")
     */
    private $plannings;

    /**
     * @ORM\OneToMany(targetEntity=TypePlanification::class, mappedBy="type_duree")
     */
    private $typePlanifications;

    public function __construct()
    {
        $this->plannings = new ArrayCollection();
        $this->typePlanifications = 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, Planning>
     */
    public function getPlannings(): Collection
    {
        return $this->plannings;
    }

    public function addPlanning(Planning $planning): self
    {
        if (!$this->plannings->contains($planning)) {
            $this->plannings[] = $planning;
            $planning->setTypeDuree($this);
        }

        return $this;
    }

    public function removePlanning(Planning $planning): self
    {
        if ($this->plannings->removeElement($planning)) {
            // set the owning side to null (unless already changed)
            if ($planning->getTypeDuree() === $this) {
                $planning->setTypeDuree(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, TypePlanification>
     */
    public function getTypePlanifications(): Collection
    {
        return $this->typePlanifications;
    }

    public function addTypePlanification(TypePlanification $typePlanification): self
    {
        if (!$this->typePlanifications->contains($typePlanification)) {
            $this->typePlanifications[] = $typePlanification;
            $typePlanification->setTypeDuree($this);
        }

        return $this;
    }

    public function removeTypePlanification(TypePlanification $typePlanification): self
    {
        if ($this->plannings->removeElement($typePlanification)) {
            // set the owning side to null (unless already changed)
            if ($typePlanification->getTypeDuree() === $this) {
                $typePlanification->setTypeDuree(null);
            }
        }

        return $this;
    }
}
