<?php

namespace App\Entity;

use App\Repository\TypeEmailRepository;
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=TypeEmailRepository::class)
 * @ORM\Table(schema="sav")
 */
class TypeEmail
{
    Const ID_EMAIL_PRO = 1;
    Const ID_EMAIL_PERSO = 2;
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({"api"})
     */
    private $id;

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

    /**
     * @ORM\OneToMany(targetEntity=UtilisateurEmail::class, mappedBy="type_email")
     * @Ignore()
     */
    private $utilisateurEmails;

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

    public function addUtilisateurEmail(UtilisateurEmail $utilisateurEmail): self
    {
        if (!$this->utilisateurEmails->contains($utilisateurEmail)) {
            $this->utilisateurEmails[] = $utilisateurEmail;
            $utilisateurEmail->setTypeEmail($this);
        }

        return $this;
    }

    public function removeUtilisateurEmail(UtilisateurEmail $utilisateurEmail): self
    {
        if ($this->utilisateurEmails->removeElement($utilisateurEmail)) {
            // set the owning side to null (unless already changed)
            if ($utilisateurEmail->getTypeEmail() === $this) {
                $utilisateurEmail->setTypeEmail(null);
            }
        }

        return $this;
    }
}
