<?php

namespace App\Entity;

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

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

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

    /**
     * @ORM\Column(type="boolean", nullable=true)
     */
    private $actif;

    /**
     * @ORM\OneToMany(targetEntity=InterventionAnnulation::class, mappedBy="intervention_motif_abandon")
     */
    private $interventionAnnulations;

    public function __construct()
    {
        $this->interventionAnnulations = 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;
    }

    public function getActif(): ?bool
    {
        return $this->actif;
    }

    public function setActif(?bool $actif): self
    {
        $this->actif = $actif;

        return $this;
    }

    /**
     * @return Collection<int, InterventionAnnulation>
     */
    public function getInterventionAnnulations(): Collection
    {
        return $this->interventionAnnulations;
    }

    public function addInterventionAnnulation(InterventionAnnulation $interventionAnnulation): self
    {
        if (!$this->interventionAnnulations->contains($interventionAnnulation)) {
            $this->interventionAnnulations[] = $interventionAnnulation;
            $interventionAnnulation->setInterventionMotifAbandon($this);
        }

        return $this;
    }

    public function removeInterventionAnnulation(InterventionAnnulation $interventionAnnulation): self
    {
        if ($this->interventionAnnulations->removeElement($interventionAnnulation)) {
            // set the owning side to null (unless already changed)
            if ($interventionAnnulation->getInterventionMotifAbandon() === $this) {
                $interventionAnnulation->setInterventionMotifAbandon(null);
            }
        }

        return $this;
    }
}
