<?php

namespace App\Entity;

use App\Repository\CategoriePlanificationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=CategoriePlanificationRepository::class)
 * @ORM\Table(schema="sav")
 */
class CategoriePlanification
{
    Const ID_CATEG_CLIENT = 1;
    Const ID_CATEG_INTERNE = 2;
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

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

    /**
     * @ORM\Column(type="boolean")
     */
    private $flag_validation;

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

    public function __construct()
    {
        $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;
    }

    public function getFlagValidation(): ?bool
    {
        return $this->flag_validation;
    }

    public function setFlagValidation(bool $flag_validation): self
    {
        $this->flag_validation = $flag_validation;

        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->setCategoriePlanification($this);
        }

        return $this;
    }

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

        return $this;
    }

    public function isInterne() {
        return ($this->id === self::ID_CATEG_INTERNE);
    }
}
