<?php

namespace App\Entity;

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

/**
 * @ORM\Entity(repositoryClass=CommunicationTypeRepository::class)
 * @ORM\Table(schema="sav")
 */
class CommunicationType
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

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

    /**
     * @ORM\OneToMany(targetEntity=CommunicationClient::class, mappedBy="communication_type")
     */
    private $communicationClients;

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

    public function addCommunicationClient(CommunicationClient $communicationClient): self
    {
        if (!$this->communicationClients->contains($communicationClient)) {
            $this->communicationClients[] = $communicationClient;
            $communicationClient->setCommunicationType($this);
        }

        return $this;
    }

    public function removeCommunicationClient(CommunicationClient $communicationClient): self
    {
        if ($this->communicationClients->removeElement($communicationClient)) {
            // set the owning side to null (unless already changed)
            if ($communicationClient->getCommunicationType() === $this) {
                $communicationClient->setCommunicationType(null);
            }
        }

        return $this;
    }
}
