<?php

namespace App\Entity;

use App\Repository\PointControleRepository;
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=PointControleRepository::class)
 * @ORM\Table(schema="sav")
 */
class PointControle
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({"api"})
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=250, nullable=true)
     * @Groups({"api"})
     */
    private $libelle;

    /**
     * @ORM\Column(type="string", length=50, nullable=true)
     * @Groups({"api"})
     */
    private $valeur_defaut;

    /**
     * @ORM\OneToMany(targetEntity=AttestationEntretienPointControle::class, mappedBy="point_controle")
     */
    private $attestationEntretienPointControles;

    /**
     * @ORM\Column(type="json", nullable=true)
     * @Groups({"api"})
     */
    private $valeurs_possible = [];

    /**
     * @ORM\Column(type="boolean", nullable=true)
     * @Groups({"api"})
     */
    private $obligatoire;

    /**
     * @ORM\Column(type="boolean", nullable=true)
     * @Groups({"api"})
     */
    private $pac;


    public function __construct()
    {
        $this->attestationEntretienPointControles = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function setId(?int $id): self
    {
        $this->id = $id;

        return $this;
    }

    public function getLibelle(): ?string
    {
        return $this->libelle;
    }

    public function setLibelle(?string $libelle): self
    {
        $this->libelle = $libelle;

        return $this;
    }

    public function getValeurDefaut(): ?string
    {
        return $this->valeur_defaut;
    }

    public function setValeurDefaut(?string $valeur_defaut): self
    {
        $this->valeur_defaut = $valeur_defaut;

        return $this;
    }

    /**
     * @return Collection<int, AttestationEntretienPointControle>
     */
    public function getAttestationEntretienPointControles(): Collection
    {
        return $this->attestationEntretienPointControles;
    }

    public function addAttestationEntretienPointControle(AttestationEntretienPointControle $attestationEntretienPointControle): self
    {
        if (!$this->attestationEntretienPointControles->contains($attestationEntretienPointControle)) {
            $this->attestationEntretienPointControles[] = $attestationEntretienPointControle;
            $attestationEntretienPointControle->setPointControle($this);
        }

        return $this;
    }

    public function removeAttestationEntretienPointControle(AttestationEntretienPointControle $attestationEntretienPointControle): self
    {
        if ($this->attestationEntretienPointControles->removeElement($attestationEntretienPointControle)) {
            // set the owning side to null (unless already changed)
            if ($attestationEntretienPointControle->getPointControle() === $this) {
                $attestationEntretienPointControle->setPointControle(null);
            }
        }

        return $this;
    }

    public function getValeursPossible(): ?array
    {
        return $this->valeurs_possible;
    }

    public function setValeursPossible(?array $valeurs_possible): self
    {
        $this->valeurs_possible = $valeurs_possible;

        return $this;
    }

    public function getObligatoire(): ?bool
    {
        return $this->obligatoire;
    }

    public function setObligatoire(?bool $obligatoire): self
    {
        $this->obligatoire = $obligatoire;

        return $this;
    }

    public function getPac(): ?bool
    {
        return $this->pac;
    }

    public function setPac(?bool $pac): self
    {
        $this->pac = $pac;

        return $this;
    }
}
