<?php

namespace App\Entity;

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

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

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

    /**
     * @ORM\Column(type="string", length=40, nullable=true)
     */
    private $libelle_client;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    private $rang_tri;

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

    /**
     * @ORM\OneToMany(targetEntity=PlanningHistoriqueModification::class, mappedBy="moment_passage")
     */
    private $planningHistoriqueModifications;

    public function __construct()
    {
        $this->plannings = new ArrayCollection();
        $this->planningHistoriqueModifications = 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;
    }

    public function getLibellePlanning(): ?string
    {
        return $this->libelle_planning;
    }

    public function setLibellePlanning(?string $libelle_planning): self
    {
        $this->libelle_planning = $libelle_planning;

        return $this;
    }

    public function getLibelleClient(): ?string
    {
        return $this->libelle_client;
    }

    public function setLibelleClient(?string $libelle_client): self
    {
        $this->libelle_client = $libelle_client;

        return $this;
    }

    public function getRangTri(): ?int
    {
        return $this->rang_tri;
    }

    public function setRangTri(?int $rang_tri): self
    {
        $this->rang_tri = $rang_tri;

        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->setMomentPassage($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->getMomentPassage() === $this) {
                $planning->setMomentPassage(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, PlanningHistoriqueModification>
     */
    public function getPlanningHistoriqueModifications(): Collection
    {
        return $this->planningHistoriqueModifications;
    }

    public function addPlanningHistoriqueModification(PlanningHistoriqueModification $planningHistoriqueModification): self
    {
        if (!$this->planningHistoriqueModifications->contains($planningHistoriqueModification)) {
            $this->planningHistoriqueModifications[] = $planningHistoriqueModification;
            $planningHistoriqueModification->setMomentPassage($this);
        }

        return $this;
    }

    public function removePlanningHistoriqueModification(PlanningHistoriqueModification $planningHistoriqueModification): self
    {
        if ($this->planningHistoriqueModifications->removeElement($planningHistoriqueModification)) {
            // set the owning side to null (unless already changed)
            if ($planningHistoriqueModification->getMomentPassage() === $this) {
                $planningHistoriqueModification->setMomentPassage(null);
            }
        }

        return $this;
    }
}
