<?php

namespace App\Enums;

enum GameStatusEnum: int
{
    case ACTIVE   = 1;
    case INACTIVE = 2;

    public static function labels(): array
    {
        return [
            self::ACTIVE->value   => __('Active'),
            self::INACTIVE->value => __('Inactive'),
        ];
    }

    public static function label(self|int|null $value): string
    {
        $key = $value instanceof self ? $value->value : $value;
        return self::labels()[$key] ?? '';
    }

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

    public static function colors(): array
    {
        return [
            self::ACTIVE->value   => 'success',
            self::INACTIVE->value => 'danger',
        ];
    }

    public static function color(self|int|null $value): string
    {
        $key = $value instanceof self ? $value->value : $value;
        return self::colors()[$key] ?? 'secondary';
    }

    public static function badge(self|int|null $value): string
    {
        $color = self::color($value);
        $label = self::label($value);
        return '<span class="badge bg-' . $color . '-subtle text-' . $color . '">' . $label . '</span>';
    }

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