<?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: 'vessel')]
class Vessel
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\ManyToOne(targetEntity: ShippingCompany::class, inversedBy: 'vessels')]
    #[ORM\JoinColumn(nullable: false)]
    private ShippingCompany $company;

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

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

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

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

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

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

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $imoNo = null;

    #[ORM\Column(length: 255, nullable: true)]
    private ?string $callSign = null;

    #[ORM\Column]
    private DateTimeImmutable $createdAt;

    #[ORM\OneToMany(targetEntity: Trip::class, mappedBy: 'vessel')]
    private Collection $trips;

    public function __construct(ShippingCompany $company, string $name, string $code)
    {
        $this->company = $company;
        $this->name = $name;
        $this->code = $code;
        $this->createdAt = new DateTimeImmutable();
        $this->trips = new ArrayCollection();
    }

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

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

    public function setCompany(ShippingCompany $company): self
    {
        $this->company = $company;
        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 getLength(): ?float
    {
        return $this->length;
    }

    public function setLength(?float $length): void
    {
        $this->length = $length;
    }

    public function getBreadth(): ?float
    {
        return $this->breadth;
    }

    public function setBreadth(?float $breadth): void
    {
        $this->breadth = $breadth;
    }

    public function getDraft(): ?float
    {
        return $this->draft;
    }

    public function setDraft(?float $draft): void
    {
        $this->draft = $draft;
    }

    public function getGrossTonnage(): ?float
    {
        return $this->grossTonnage;
    }

    public function setGrossTonnage(?float $grossTonnage): void
    {
        $this->grossTonnage = $grossTonnage;
    }

    public function getImoNo(): ?string
    {
        return $this->imoNo;
    }

    public function setImoNo(?string $imoNo): void
    {
        $this->imoNo = $imoNo;
    }

    public function getCallSign(): ?string
    {
        return $this->callSign;
    }

    public function setCallSign(?string $callSign): void
    {
        $this->callSign = $callSign;
    }

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

    public function getTrips(): Collection
    {
        return $this->trips;
    }
}