<?php

namespace App\Entity;

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

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

    /**
     * @ORM\OneToMany(targetEntity=Appareil::class, mappedBy="type_appareil")
     */
    private $appareils;

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

    public function addAppareil(Appareil $appareil): self
    {
        if (!$this->appareils->contains($appareil)) {
            $this->appareils[] = $appareil;
            $appareil->setTypeAppareil($this);
        }

        return $this;
    }

    public function removeAppareil(Appareil $appareil): self
    {
        if ($this->appareils->removeElement($appareil)) {
            // set the owning side to null (unless already changed)
            if ($appareil->getTypeAppareil() === $this) {
                $appareil->setTypeAppareil(null);
            }
        }

        return $this;
    }
}
