<?php

namespace App\Entity;

use App\Repository\Cible2063Repository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=Cible2063Repository::class)
 */
class Cible2063
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

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

    /**
     * @ORM\Column(type="text")
     */
    private $name;

    /**
     * @ORM\ManyToOne(targetEntity=Indicator::class, inversedBy="cibles")
     */
    private $domaine;

    /**
     * @ORM\OneToMany(targetEntity=Indicateur2063::class, mappedBy="cible")
     */
    private $indicateurs;

    public function __construct()
    {
        $this->indicateurs = new ArrayCollection();
    }

    public function __toString()
    {
        return $this->getCode() . ' - ' . $this->getName();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }

    public function getDomaine(): ?Indicator
    {
        return $this->domaine;
    }

    public function setDomaine(?Indicator $domaine): self
    {
        $this->domaine = $domaine;

        return $this;
    }

    public function getCode(): ?string
    {
        return $this->code;
    }

    public function setCode(string $code): self
    {
        $this->code = $code;

        return $this;
    }

    /**
     * @return Collection<int, Indicateur2063>
     */
    public function getIndicateurs(): Collection
    {
        return $this->indicateurs;
    }

    public function addIndicateur(Indicateur2063 $indicateur): self
    {
        if (!$this->indicateurs->contains($indicateur)) {
            $this->indicateurs[] = $indicateur;
            $indicateur->setCible($this);
        }

        return $this;
    }

    public function removeIndicateur(Indicateur2063 $indicateur): self
    {
        if ($this->indicateurs->removeElement($indicateur)) {
            // set the owning side to null (unless already changed)
            if ($indicateur->getCible() === $this) {
                $indicateur->setCible(null);
            }
        }

        return $this;
    }
}
