<?php

namespace App\Entity;

use App\Entity\User\User;
use App\Repository\CollectifDataRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Doctrine\Extension\StatusInterface;
use Lc\SovBundle\Doctrine\Extension\StatusTrait;

/**
 * @ORM\Entity(repositoryClass=CollectifDataRepository::class)
 */
class CollectifData implements StatusInterface, EntityInterface
{
    use StatusTrait;

    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="integer")
     */
    private $nbParticipant;

    /**
     * @ORM\ManyToOne(targetEntity=User::class, inversedBy="collectifData")
     */
    private $user;

    /**
     * @ORM\OneToMany(targetEntity=Revolts::class, mappedBy="collectifData", cascade={"persist", "remove"})
     */
    private $revolts;

    /**
     * @ORM\OneToMany(targetEntity=Dreams::class, mappedBy="collectifData", cascade={"persist", "remove"})
     */
    private $dreams;

    /**
     * @ORM\OneToMany(targetEntity=ProjectsBoost::class, mappedBy="collectifData", cascade={"persist", "remove"})
     */
    private $projectsBoost;

    /**
     * @ORM\OneToMany(targetEntity=ProjectsInspiring::class, mappedBy="collectifData", cascade={"persist", "remove"})
     */
    private $projectsInspiring;

    /**
     * @ORM\ManyToOne(targetEntity=Territory::class, inversedBy="collectifData")
     */
    private $territory;

    public function __construct()
    {
        $this->revolts = new ArrayCollection();
        $this->dreams = new ArrayCollection();
        $this->projectsBoost = new ArrayCollection();
        $this->projectsInspiring = new ArrayCollection();
    }

    public function __toString()
    {
        return $this->nbParticipant . " participants";
    }

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

    public function getNbParticipant(): ?int
    {
        return $this->nbParticipant;
    }

    public function setNbParticipant(int $nbParticipant): self
    {
        $this->nbParticipant = $nbParticipant;

        return $this;
    }

    public function getUser(): ?User
    {
        return $this->user;
    }

    public function setUser(?User $user): self
    {
        $this->user = $user;

        return $this;
    }

    /**
     * @return Collection|Revolts[]
     */
    public function getRevolts(): Collection
    {
        return $this->revolts;
    }

    public function addRevolt(Revolts $revolt): self
    {
        if (!$this->revolts->contains($revolt)) {
            $this->revolts[] = $revolt;
            $revolt->setCollectifData($this);
        }

        return $this;
    }

    public function removeRevolt(Revolts $revolt): self
    {
        if ($this->revolts->removeElement($revolt)) {
            // set the owning side to null (unless already changed)
            if ($revolt->getCollectifData() === $this) {
                $revolt->setCollectifData(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|Dreams[]
     */
    public function getDreams(): Collection
    {
        return $this->dreams;
    }

    public function addDream(Dreams $dream): self
    {
        if (!$this->dreams->contains($dream)) {
            $this->dreams[] = $dream;
            $dream->setCollectifData($this);
        }

        return $this;
    }

    public function removeDream(Dreams $dream): self
    {
        if ($this->dreams->removeElement($dream)) {
            // set the owning side to null (unless already changed)
            if ($dream->getCollectifData() === $this) {
                $dream->setCollectifData(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|ProjectsBoost[]
     */
    public function getProjectsBoost(): Collection
    {
        return $this->projectsBoost;
    }

    public function addProjectsBoost(ProjectsBoost $projectsBoost): self
    {
        if (!$this->projectsBoost->contains($projectsBoost)) {
            $this->projectsBoost[] = $projectsBoost;
            $projectsBoost->setCollectifData($this);
        }

        return $this;
    }

    public function removeProjectsBoost(ProjectsBoost $projectsBoost): self
    {
        if ($this->projectsBoost->removeElement($projectsBoost)) {
            // set the owning side to null (unless already changed)
            if ($projectsBoost->getCollectifData() === $this) {
                $projectsBoost->setCollectifData(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|ProjectsInspiring[]
     */
    public function getProjectsInspiring(): Collection
    {
        return $this->projectsInspiring;
    }

    public function addProjectsInspiring(ProjectsInspiring $projectsInspiring): self
    {
        if (!$this->projectsInspiring->contains($projectsInspiring)) {
            $this->projectsInspiring[] = $projectsInspiring;
            $projectsInspiring->setCollectifData($this);
        }

        return $this;
    }

    public function removeProjectsInspiring(ProjectsInspiring $projectsInspiring): self
    {
        if ($this->projectsInspiring->removeElement($projectsInspiring)) {
            // set the owning side to null (unless already changed)
            if ($projectsInspiring->getCollectifData() === $this) {
                $projectsInspiring->setCollectifData(null);
            }
        }

        return $this;
    }

    public function getTerritory(): ?Territory
    {
        return $this->territory;
    }

    public function setTerritory(?Territory $territory): self
    {
        $this->territory = $territory;

        return $this;
    }
}
