<?php

namespace App\Enums;

enum TaskStatus: string
{
    case TODO = 'todo';
    case IN_PROGRESS = 'in_progress';
    case DONE = 'done';
    case CANCELLED = 'cancelled';

    public function label(): string
    {
        return match ($this) {
            self::TODO => 'Cần làm',
            self::IN_PROGRESS => 'Đang thực hiện',
            self::DONE => 'Hoàn thành',
            self::CANCELLED => 'Đã hủy',
        };
    }

    public function cssClass(): string
    {
        return 'status-badge--' . $this->value;
    }

    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }

    public static function default(): self
    {
        return self::TODO;
    }

    public static function options(): array
    {
        return array_map(fn($case) => [
            'value' => $case->value,
            'label' => $case->label(),
            'cssClass' => $case->cssClass(),
        ], self::cases());
    }
}
