<?php

namespace App\Entity;

use App\Repository\OrderNumberRepository;
use Doctrine\ORM\Mapping as ORM;

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

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

    #[ORM\Column]
    private \DateTimeImmutable $createdAt;

    #[ORM\Column]
    private bool $isUsed = false;

    public function __construct(string $numOrder)
    {
        $this->numOrder = $numOrder;
        $this->createdAt = new \DateTimeImmutable();
    }

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

    public function getNumOrder(): string
    {
        return $this->numOrder;
    }

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

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

    public function markAsUsed(): void
    {
        $this->isUsed = true;
    }

    public function markAsUnused(): void
    {
        $this->isUsed = false;
    }
}
