<?php

namespace app\enum;

enum OrderStatus: int
{
    case CLOSE = 1;
    case PAID = 2;
    case CLUBS = 3;
    case SPADES = 4;
    /**
     * 获取所有状态映射数组
     */
    public static function toArray(): array
    {
        return [
            self::CLOSE->value => __('失败'),
            self::PAID->value => __('取消'),
            self::CLUBS->value => __('等待支付'),
            self::SPADES->value => __('完成'),
        ];
    }

    /**
     * 获取当前状态的描述文本
     */
    public function getDescription(): string
    {
        return self::toArray()[$this->value];
    }

    /**
     * 安全地从值创建枚举实例
     */
    public static function tryFromValue(int $value): ?self
    {
        return self::tryFrom($value);
    }
}
