<?php

declare(strict_types=1);

namespace App\Entity;

use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;

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

    #[ORM\ManyToOne(targetEntity: Trip::class, inversedBy: 'tripLocations')]
    #[ORM\JoinColumn(nullable: false)]
    private Trip $trip;

    #[ORM\ManyToOne(targetEntity: Location::class, inversedBy: 'tripLocations')]
    #[ORM\JoinColumn(nullable: false)]
    private Location $location;

    #[ORM\Column(nullable: true)]
    private ?DateTimeImmutable $arrivalDateTime = null;

    #[ORM\Column(nullable: true)]
    private ?DateTimeImmutable $departureDateTime = null;

    #[ORM\Column]
    private DateTimeImmutable $createdAt;

    public function __construct(Trip $trip, Location $location)
    {
        $this->trip = $trip;
        $this->location = $location;
        $this->createdAt = new DateTimeImmutable();
    }

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

    public function getTrip(): Trip
    {
        return $this->trip;
    }

    public function setTrip(Trip $trip): self
    {
        $this->trip = $trip;
        return $this;
    }

    public function getLocation(): Location
    {
        return $this->location;
    }

    public function setLocation(Location $location): self
    {
        $this->location = $location;
        return $this;
    }

    public function getArrivalDateTime(): ?DateTimeImmutable
    {
        return $this->arrivalDateTime;
    }

    public function setArrivalDateTime(?DateTimeImmutable $arrivalDateTime): void
    {
        $this->arrivalDateTime = $arrivalDateTime;
    }

    public function getDepartureDateTime(): ?DateTimeImmutable
    {
        return $this->departureDateTime;
    }

    public function setDepartureDateTime(?DateTimeImmutable $departureDateTime): void
    {
        $this->departureDateTime = $departureDateTime;
    }

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