<?php

namespace App\Entity;

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

/**
 * @ORM\Table(schema="sav")
 * @ORM\Entity(repositoryClass=GroupeTypeRepository::class)
 */
class GroupeType
{
    const ID_TCHAT_AGENT = 1;
    const ID_TCHAT_INTERNE = 2;
    const ID_TCHAT_GROUPE = 3;
    const ID_POLE = 4;
    const ID_PLANNING = 5;
    const TYPE_COLOR = [
        self::ID_TCHAT_AGENT => 'bg-orange',
        self::ID_TCHAT_INTERNE => 'bg-primary',
        self::ID_TCHAT_GROUPE => 'bg-vert'
    ];

    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

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

    /**
     * @ORM\OneToMany(targetEntity=Groupe::class, mappedBy="type")
     * @Ignore()
     */
    private $groupes;

    public function __construct()
    {
        $this->groupes = 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|Groupe[]
     */
    public function getGroupes(): Collection
    {
        return $this->groupes;
    }

    public function addGroupe(Groupe $groupe): self
    {
        if (!$this->groupes->contains($groupe)) {
            $this->groupes[] = $groupe;
            $groupe->setType($this);
        }

        return $this;
    }

    public function removeGroupe(Groupe $groupe): self
    {
        if ($this->groupes->removeElement($groupe)) {
            // set the owning side to null (unless already changed)
            if ($groupe->getType() === $this) {
                $groupe->setType(null);
            }
        }

        return $this;
    }
}
