<?php

namespace App\Entity;

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

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

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

    /**
     * @ORM\OneToMany(targetEntity=UtilisateurAffectation::class, mappedBy="motif_temps_partiel")
     * @Ignore()
     */
    private $utilisateurAffectations;

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

    public function addUtilisateurAffectation(UtilisateurAffectation $utilisateurAffectation): self
    {
        if (!$this->utilisateurAffectations->contains($utilisateurAffectation)) {
            $this->utilisateurAffectations[] = $utilisateurAffectation;
            $utilisateurAffectation->setMotifTempsPartiel($this);
        }

        return $this;
    }

    public function removeUtilisateurAffectation(UtilisateurAffectation $utilisateurAffectation): self
    {
        if ($this->utilisateurAffectations->removeElement($utilisateurAffectation)) {
            // set the owning side to null (unless already changed)
            if ($utilisateurAffectation->getMotifTempsPartiel() === $this) {
                $utilisateurAffectation->setMotifTempsPartiel(null);
            }
        }

        return $this;
    }
}
