<?php

namespace App\Entity;

use App\Repository\AnnouncementRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

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

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

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

    #[ORM\ManyToOne(inversedBy: 'announcements')]
    #[ORM\JoinColumn(nullable: false)]
    private ?Company $company = null;

    #[ORM\Column(nullable: false)]
    private ?string $status = "notVerfied";

    #[ORM\Column(nullable: false)]
    private ?string $date = null;

    #[ORM\Column(type: Types::DATE_MUTABLE)]
    private ?\DateTimeInterface $creationDate = null;

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

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

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

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

    public function getTitle(): ?string
    {
        return $this->title;
    }

    public function setTitle(string $title): static
    {
        $this->title = $title;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(string $description): static
    {
        $this->description = $description;

        return $this;
    }

    public function getCompany(): ?Company
    {
        return $this->company;
    }

    public function setCompany(?Company $company): static
    {
        $this->company = $company;

        return $this;
    }

    public function getStatus(): ?string
    {
        return $this->status;
    }

    public function setStatus(?string $status): self
    {
        $this->status = $status;

        return $this;
    }

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

    public function addApplicants(InternApplication $applicants): static
    {
        if (!$this->applicants->contains($applicants)) {
            $this->applicants->add($applicants);
            $applicants->setApplication($this);
        }

        return $this;
    }

    public function removeApplicants(InternApplication $applicants): static
    {
        if ($this->applicants->removeElement($applicants)) {
            // set the owning side to null (unless already changed)
            if ($applicants->getApplication() === $this) {
                $applicants->setApplication(null);
            }
        }

        return $this;
    }

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

    public function addFavoritesIntern(InternFavorite $favoritesIntern): static
    {
        if (!$this->favoritesInterns->contains($favoritesIntern)) {
            $this->favoritesInterns->add($favoritesIntern);
            $favoritesIntern->setAnnouncement($this);
        }

        return $this;
    }

    public function removeFavoritesIntern(InternFavorite $favoritesIntern): static
    {
        if ($this->favoritesInterns->removeElement($favoritesIntern)) {
            // set the owning side to null (unless already changed)
            if ($favoritesIntern->getAnnouncement() === $this) {
                $favoritesIntern->setAnnouncement(null);
            }
        }

        return $this;
    }

    public function getCreationDate(): ?\DateTimeInterface
    {
        return $this->creationDate;
    }

    public function setCreationDate(\DateTimeInterface $creationDate): static
    {
        $this->creationDate = $creationDate;

        return $this;
    }

    public function getDate(): ?string
    {
        return $this->date;
    }

    public function setDate(string $date): self
    {
        $this->date = $date;
        return $this;
    }

}