<?php

namespace App\Entity;

use App\Repository\ThematicRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;

/**
 * @ORM\Entity(repositoryClass=ThematicRepository::class)
 */
class Thematic implements EntityInterface
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

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

    /**
     * @ORM\OneToMany(targetEntity=Subthematic::class, mappedBy="thematic", cascade={"persist", "remove"})
     */
    private $subthematic;


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

    public function __toString()
    {
        return $this->name;
    }

    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;
    }

    /**
     * @return Collection|Subthematic[]
     */
    public function getSubthematic(): Collection
    {
        return $this->subthematic;
    }

    public function addSubthematic(Subthematic $subthematic): self
    {
        if (!$this->subthematic->contains($subthematic)) {
            $this->subthematic[] = $subthematic;
            $subthematic->setThematic($this);
        }

        return $this;
    }

    public function removeSubthematic(Subthematic $subthematic): self
    {
        if ($this->subthematic->removeElement($subthematic)) {
            // set the owning side to null (unless already changed)
            if ($subthematic->getThematic() === $this) {
                $subthematic->setThematic(null);
            }
        }

        return $this;
    }
}
