<?php

namespace App\Entity;

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

#[ORM\Entity(repositoryClass: DegreeRepository::class)]
class Degree
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(length: 255)]
    private ?string $label = null;

    /**
     * @var Collection<int, InternDegree>
     */
    #[ORM\OneToMany(targetEntity: InternDegree::class, mappedBy: 'degree')]
    private Collection $interns;

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

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

    public function getLabel(): ?string
    {
        return $this->label;
    }

    public function setLabel(string $label): static
    {
        $this->label = $label;

        return $this;
    }

    /**
     * @return Collection<int, InternDegree>
     */
    public function getInterns(): Collection
    {
        return $this->interns;
    }

    public function addIntern(InternDegree $intern): static
    {
        if (!$this->interns->contains($intern)) {
            $this->interns->add($intern);
            $intern->setDegree($this);
        }

        return $this;
    }

    public function removeIntern(InternDegree $intern): static
    {
        if ($this->interns->removeElement($intern)) {
            // set the owning side to null (unless already changed)
            if ($intern->getDegree() === $this) {
                $intern->setDegree(null);
            }
        }

        return $this;
    }
}
