<?php

namespace App\Entity;

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

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

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

    /**
     * @var Collection<int, InternSkill>
     */
    #[ORM\OneToMany(targetEntity: InternSkill::class, mappedBy: 'skill')]
    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, InternSkill>
     */
    public function getInterns(): Collection
    {
        return $this->interns;
    }

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

        return $this;
    }

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

        return $this;
    }
}
