<?php

namespace App\Entity;

use App\Repository\LigneRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: LigneRepository::class)]
class Ligne
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(length: 1)]
    private ?string $rang = null;

    #[ORM\Column]
    private ?float $prix_dim_1 = null;

    #[ORM\Column]
    private ?float $prix_dim_2 = null;

    #[ORM\Column]
    private ?float $prix_dim_3 = null;

    #[ORM\Column]
    private ?float $prix_dim_4 = null;

    #[ORM\Column(type: Types::DATETIME_MUTABLE)]
    private ?\DateTimeInterface $date_update = null;

    #[ORM\ManyToOne(inversedBy: 'lignes')]
    #[ORM\JoinColumn(nullable: false)]
    private ?User $create_by = null;

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

    public function getRang(): ?string
    {
        return $this->rang;
    }

    public function setRang(string $rang): static
    {
        $this->rang = $rang;

        return $this;
    }

    public function getPrixDim1(): ?float
    {
        return $this->prix_dim_1;
    }

    public function setPrixDim1(float $prix_dim_1): static
    {
        $this->prix_dim_1 = $prix_dim_1;

        return $this;
    }

    public function getPrixDim2(): ?float
    {
        return $this->prix_dim_2;
    }

    public function setPrixDim2(float $prix_dim_2): static
    {
        $this->prix_dim_2 = $prix_dim_2;

        return $this;
    }

    public function getPrixDim3(): ?float
    {
        return $this->prix_dim_3;
    }

    public function setPrixDim3(float $prix_dim_3): static
    {
        $this->prix_dim_3 = $prix_dim_3;

        return $this;
    }

    public function getPrixDim4(): ?float
    {
        return $this->prix_dim_4;
    }

    public function setPrixDim4(float $prix_dim_4): static
    {
        $this->prix_dim_4 = $prix_dim_4;

        return $this;
    }

    public function getPrixByBimension(int $dim): ?float
    {
        return match ($dim) {
            1 => $this->prix_dim_1,
            2 => $this->prix_dim_2,
            3 => $this->prix_dim_3,
            4 => $this->prix_dim_4,

        };
    }

    public function getDateUpdate(): ?\DateTimeInterface
    {
        return $this->date_update;
    }

    public function setDateUpdate(\DateTimeInterface $date_update): static
    {
        $this->date_update = $date_update;

        return $this;
    }

    public function getCreateBy(): ?User
    {
        return $this->create_by;
    }

    public function setCreateBy(?User $create_by): static
    {
        $this->create_by = $create_by;

        return $this;
    }
}
