<?php

namespace App\Entity;

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

/**
 * @ORM\Entity(repositoryClass=MainstayRepository::class)
 */
class Mainstay
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

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

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

    /**
     * @ORM\OneToMany(targetEntity=Accelerator::class, mappedBy="mainstay")
     */
    private $accelerators;

    /**
     * @ORM\OneToMany(targetEntity=ActivityOSC::class, mappedBy="mainstay")
     */
    private $activityOSCs;

    /**
     * @ORM\OneToMany(targetEntity=Goal::class, mappedBy="mainstay")
     */
    private $goals;

    /**
     * @ORM\Column(type="string", length=8, nullable=true)
     */
    private $color;

    public function __construct()
    {
        $this->accelerators = new ArrayCollection();
        $this->activityOSCs = new ArrayCollection();
        $this->goals = new ArrayCollection();
    }

    public function __toString()
    {
        return $this->getCode() . ' - ' . $this->getName();
    }

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

    public function getCode(): ?string
    {
        return $this->code;
    }

    public function setCode(string $code): self
    {
        $this->code = $code;

        return $this;
    }

    /**
     * @return Collection|Accelerator[]
     */
    public function getAccelerators(): Collection
    {
        return $this->accelerators;
    }

    public function addAccelerator(Accelerator $accelerator): self
    {
        if (!$this->accelerators->contains($accelerator)) {
            $this->accelerators[] = $accelerator;
            $accelerator->setMainstay($this);
        }

        return $this;
    }

    public function removeAccelerator(Accelerator $accelerator): self
    {
        if ($this->accelerators->contains($accelerator)) {
            $this->accelerators->removeElement($accelerator);
            // set the owning side to null (unless already changed)
            if ($accelerator->getMainstay() === $this) {
                $accelerator->setMainstay(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|ActivityOSC[]
     */
    public function getActivityOSCs(): Collection
    {
        return $this->activityOSCs;
    }

    public function addActivityOSC(ActivityOSC $activityOSC): self
    {
        if (!$this->activityOSCs->contains($activityOSC)) {
            $this->activityOSCs[] = $activityOSC;
            $activityOSC->setMainstay($this);
        }

        return $this;
    }

    public function removeActivityOSC(ActivityOSC $activityOSC): self
    {
        if ($this->activityOSCs->contains($activityOSC)) {
            $this->activityOSCs->removeElement($activityOSC);
            // set the owning side to null (unless already changed)
            if ($activityOSC->getMainstay() === $this) {
                $activityOSC->setMainstay(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|Goal[]
     */
    public function getGoals(): Collection
    {
        return $this->goals;
    }

    public function addGoal(Goal $goal): self
    {
        if (!$this->goals->contains($goal)) {
            $this->goals[] = $goal;
            $goal->setMainstay($this);
        }

        return $this;
    }

    public function removeGoal(Goal $goal): self
    {
        if ($this->goals->contains($goal)) {
            $this->goals->removeElement($goal);
            // set the owning side to null (unless already changed)
            if ($goal->getMainstay() === $this) {
                $goal->setMainstay(null);
            }
        }

        return $this;
    }

    public function getColor(): ?string
    {
        return $this->color;
    }

    public function setColor(?string $color): self
    {
        $this->color = $color;

        return $this;
    }
}
