<?php

declare(strict_types=1);

namespace App\Entity;

use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'location')]
class Location
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\ManyToOne(targetEntity: Zone::class, inversedBy: 'locations')]
    #[ORM\JoinColumn(nullable: false)]
    private Zone $zone;

    #[ORM\Column(length: 255)]
    private string $code;

    #[ORM\Column(length: 255)]
    private string $name;

    #[ORM\Column(nullable: false)]
    private bool $isZone = false;

    #[ORM\Column(nullable: false)]
    private bool $isPlace = false;

    #[ORM\Column(nullable: false)]
    private bool $isPort = false;

    #[ORM\Column(nullable: false)]
    private bool $isStartEnd = false;

    #[ORM\Column]
    private DateTimeImmutable $createdAt;

    #[ORM\OneToMany(targetEntity: TripLocation::class, mappedBy: 'location')]
    private Collection $tripLocations;

    public function __construct(Zone $zone, string $name, string $code)
    {
        $this->zone = $zone;
        $this->name = $name;
        $this->code = $code;
        $this->createdAt = new DateTimeImmutable();
        $this->tripLocations = new ArrayCollection();
    }

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

    public function getZone(): Zone
    {
        return $this->zone;
    }

    public function setZone(Zone $zone): self
    {
        $this->zone = $zone;
        return $this;
    }

    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): void
    {
        $this->code = $code;
    }

    public function isZone(): bool
    {
        return $this->isZone;
    }

    public function setIsZone(bool $isZone): void
    {
        $this->isZone = $isZone;
    }

    public function isPlace(): bool
    {
        return $this->isPlace;
    }

    public function setIsPlace(bool $isPlace): void
    {
        $this->isPlace = $isPlace;
    }

    public function isPort(): bool
    {
        return $this->isPort;
    }

    public function setIsPort(bool $isPort): void
    {
        $this->isPort = $isPort;
    }

    public function isStartEnd(): bool
    {
        return $this->isStartEnd;
    }

    public function setIsStartEnd(bool $isStartEnd): void
    {
        $this->isStartEnd = $isStartEnd;
    }

    public function getCreatedAt(): DateTimeImmutable
    {
        return $this->createdAt;
    }

    public function getTripLocations(): Collection
    {
        return $this->tripLocations;
    }
}