<?php

namespace App\Entity;

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

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

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

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

    /**
     * @ORM\OneToMany(targetEntity=ReviewSource::class, mappedBy="city")
     */
    private $reviewSources;

    /**
     * @ORM\OneToMany(targetEntity=Filial::class, mappedBy="city")
     */
    private $filials;

    /**
     * @ORM\OneToOne(targetEntity=Banner::class, mappedBy="city")
     */
    private $banner;

    public function __construct()
    {
        $this->filials = new ArrayCollection();
        $this->reviewSources = new ArrayCollection();
    }

    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 getTimeZone(): ?int
    {
        return $this->timeZone;
    }

    public function setTimeZone(int $timeZone): self
    {
        $this->timeZone = $timeZone;

        return $this;
    }

    public function getRegionId(): ?int
    {
        return $this->regionId;
    }

    public function setRegionId(int $regionId): self
    {
        $this->regionId = $regionId;

        return $this;
    }

    public function getBanner(): ?Banner
    {
        return $this->banner;
    }

    public function setBanner(Banner $banner): self
    {
        // set the owning side of the relation if necessary
        if ($banner->getCity() !== $this) {
            $banner->setCity($this);
        }

        $this->banner = $banner;

        return $this;
    }

    /**
     * @return Collection<int, Filial>
     */
    public function getFilials(): Collection
    {
        return $this->filials;
    }

    public function addFilial(Filial $filial): static
    {
        if (!$this->filials->contains($filial)) {
            $this->filials->add($filial);
            $filial->setCity($this);
        }

        return $this;
    }

    public function removeFilial(Filial $filial): static
    {
        if ($this->filials->removeElement($filial)) {
            // set the owning side to null (unless already changed)
            if ($filial->getCity() === $this) {
                $filial->setCity(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, ReviewSource>
     */
    public function getReviewSources(): Collection
    {
        return $this->reviewSources;
    }

    public function addReviewSource(ReviewSource $reviewSource): static
    {
        if (!$this->reviewSources->contains($reviewSource)) {
            $this->reviewSources->add($reviewSource);
            $reviewSource->setCity($this);
        }

        return $this;
    }

    public function removeReviewSource(ReviewSource $reviewSource): static
    {
        if ($this->reviewSources->removeElement($reviewSource)) {
            // set the owning side to null (unless already changed)
            if ($reviewSource->getCity() === $this) {
                $reviewSource->setCity(null);
            }
        }

        return $this;
    }
}
