<?php

namespace App\Entity;

use App\Repository\InternRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Company;

#[ORM\Entity(repositoryClass: InternRepository::class)]
class Intern extends UserApp
{

    #[ORM\Column(type: Types::TEXT,nullable: true)]
    private ?string $coverLetter = null;

    #[ORM\Column(length: 255,nullable: true)]
    private ?string $resume = null;

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

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

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

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

    public function __construct()
    {
        $this->degrees = new ArrayCollection();
        $this->skills = new ArrayCollection();
        $this->applications = new ArrayCollection();
        $this->favorites = new ArrayCollection();
    }

    public function getCoverLetter(): ?string
    {
        return $this->coverLetter;
    }

    public function setCoverLetter(string $coverLetter): static
    {
        $this->coverLetter = $coverLetter;

        return $this;
    }

    public function getResume(): ?string
    {
        return $this->resume;
    }

    public function setResume(string $resume): static
    {
        $this->resume = $resume;

        return $this;
    }

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

    public function addDegree(InternDegree $degree): static
    {
        if (!$this->degrees->contains($degree)) {
            $this->degrees->add($degree);
            $degree->setIntern($this);
        }

        return $this;
    }

    public function removeDegree(InternDegree $degree): static
    {
        if ($this->degrees->removeElement($degree)) {
            // set the owning side to null (unless already changed)
            if ($degree->getIntern() === $this) {
                $degree->setIntern(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, InternSkill>
     */
    public function getSkills(): Collection
    {
        return $this->skills;
    }

    public function addSkill(InternSkill $skill): static
    {
        if (!$this->skills->contains($skill)) {
            $this->skills->add($skill);
            $skill->setIntern($this);
        }

        return $this;
    }

    public function removeSkill(InternSkill $skill): static
    {
        if ($this->skills->removeElement($skill)) {
            // set the owning side to null (unless already changed)
            if ($skill->getIntern() === $this) {
                $skill->setIntern(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, InternApplication>
     */
    public function getApplications(): Collection
    {
        return $this->applications;
    }

    public function addApplication(InternApplication $application): static
    {
        if (!$this->applications->contains($application)) {
            $this->applications->add($application);
            $application->setIntern($this);
        }

        return $this;
    }

    public function removeApplication(InternApplication $application): static
    {
        if ($this->applications->removeElement($application)) {
            // set the owning side to null (unless already changed)
            if ($application->getIntern() === $this) {
                $application->setIntern(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, InternFavorite>
     */
    public function getFavorites(): Collection
    {
        return $this->favorites;
    }

    public function addFavorite(InternFavorite $favorite): static
    {
        if (!$this->favorites->contains($favorite)) {
            $this->favorites->add($favorite);
            $favorite->setIntern($this);
        }

        return $this;
    }

    public function removeFavorite(InternFavorite $favorite): static
    {
        if ($this->favorites->removeElement($favorite)) {
            // set the owning side to null (unless already changed)
            if ($favorite->getIntern() === $this) {
                $favorite->setIntern(null);
            }
        }

        return $this;
    }
}
