<?php

namespace App\Entity;

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

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

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

    /**
     * @ORM\OneToMany(targetEntity=Client::class, mappedBy="categorie_pro")
     * @Ignore()
     */
    private $clients;

    public function __construct()
    {
        $this->clients = 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, Client>
     */
    public function getClients(): Collection
    {
        return $this->clients;
    }

    public function addClient(Client $client): self
    {
        if (!$this->clients->contains($client)) {
            $this->clients[] = $client;
            $client->setCategoriePro($this);
        }

        return $this;
    }

    public function removeClient(Client $client): self
    {
        if ($this->clients->removeElement($client)) {
            // set the owning side to null (unless already changed)
            if ($client->getCategoriePro() === $this) {
                $client->setCategoriePro(null);
            }
        }

        return $this;
    }

    public function __toString() {
        return $this->getLibelle();
    }
}
