<?php

namespace App\Entity;

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

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

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

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

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

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $addressName;
    
    /**
    * @ORM\Column(type="integer", nullable=true)
    */
    private $siteId;

    /**
     * @ORM\ManyToOne(targetEntity=City::class, inversedBy="filials")
     */
    private $city;

    /**
     * @ORM\OneToMany(targetEntity=ReviewSource::class, mappedBy="filial", cascade={"persist", "remove"})
     */
    private $reviewSources;

    /**
     * @ORM\Column(type="boolean", options={"default" : true})
     */
    private $active;

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

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

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

    public function getFid(): ?string
    {
        return $this->fid;
    }

    public function setFid(string $fid): self
    {
        $this->fid = $fid;

        return $this;
    }

    public function getSiteId(): ?int
    {
        return $this->siteId;
    }

    public function setSiteId(string $siteId): self
    {
        $this->siteId = $siteId;

        return $this;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }

    public function getAddress(): ?string
    {
        return $this->address;
    }

    public function setAddress(string $address): self
    {
        $this->address = $address;

        return $this;
    }

    public function getAddressName(): ?string
    {
        return $this->addressName;
    }

    public function setAddressName(?string $addressName): self
    {
        $this->addressName = $addressName;

        return $this;
    }

    public function getCity(): ?City
    {
        return $this->city;
    }

    public function setCity(?City $city): self
    {
        $this->city = $city;

        return $this;
    }

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

    public function addReviewSource(ReviewSource $reviewSource): self
    {
        if (!$this->reviewSources->contains($reviewSource)) {
            $this->reviewSources[] = $reviewSource;
            $reviewSource->setFilial($this);
        }

        return $this;
    }

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

        return $this;
    }

    public function getActive(): ?bool
    {
        return $this->active;
    }

    public function setActive(bool $active): self
    {
        $this->active = $active;

        return $this;
    }

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

    public function setCompany(string $company): self
    {
        $this->company = $company;

        return $this;
    }

    public function isActive(): ?bool
    {
        return $this->active;
    }
}
