<?php

namespace App\Entity;

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

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

    /**
     * @ORM\OneToMany(targetEntity=Anomalie::class, mappedBy="anomalie_coupure_gaz")
     */
    private $anomalies;

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

    public function addAnomaly(Anomalie $anomaly): self
    {
        if (!$this->anomalies->contains($anomaly)) {
            $this->anomalies[] = $anomaly;
            $anomaly->setAnomalieCoupureGaz($this);
        }

        return $this;
    }

    public function removeAnomaly(Anomalie $anomaly): self
    {
        if ($this->anomalies->removeElement($anomaly)) {
            // set the owning side to null (unless already changed)
            if ($anomaly->getAnomalieCoupureGaz() === $this) {
                $anomaly->setAnomalieCoupureGaz(null);
            }
        }

        return $this;
    }
}
