<?php

namespace App\Enums;

enum BonusConversionStatus: string
{
    case ACTIVE = 'active';
    case COMPLETED = 'completed';
    case EXPIRED = 'expired';
    case CANCELLED = 'cancelled';

    /**
     * Get human-readable label
     */
    public function label(): string
    {
        return match($this) {
            self::ACTIVE => 'Active',
            self::COMPLETED => 'Completed',
            self::EXPIRED => 'Expired',
            self::CANCELLED => 'Cancelled',
        };
    }

    /**
     * Check if status is final (cannot be changed)
     */
    public function isFinal(): bool
    {
        return match($this) {
            self::ACTIVE => false,
            self::COMPLETED => true,
            self::EXPIRED => true,
            self::CANCELLED => true,
        };
    }

    /**
     * Check if status allows trading
     */
    public function allowsTrading(): bool
    {
        return match($this) {
            self::ACTIVE => true,
            self::COMPLETED => false,
            self::EXPIRED => false,
            self::CANCELLED => false,
        };
    }

    /**
     * Get all statuses
     */
    public static function all(): array
    {
        return [
            self::ACTIVE,
            self::COMPLETED,
            self::EXPIRED,
            self::CANCELLED,
        ];
    }

    /**
     * Get statuses as array of values
     */
    public static function values(): array
    {
        return array_map(fn($case) => $case->value, self::cases());
    }
}

// Made with Bob