<?php

namespace BWDK\Enums;

class BWDK_OrderStatus
{
    const STARTED                  = 2;
    const PENDING                  = 3;
    const WAITING_FOR_GATEWAY      = 4;
    const EXPIRED                  = 5;
    const CANCELLED                = 6;
    const PAID_BY_USER             = 7;
    const FAILED_TO_PAY            = 8;
    const VERIFIED_BY_MERCHANT     = 9;
    const FAILED_TO_VERIFY         = 10;
    const FAILED_BY_MERCHANT       = 11;
    const CANCELLED_BY_MERCHANT    = 12;
    const REFUND_BY_MERCHANT    = 13;

    /**
     * لیست تمام وضعیت‌ها با متن
     */
    public static function labels(): array
    {
        return [
            self::STARTED               => __('started', 'buy-with-digikala'),
            self::PENDING               => __('pending', 'buy-with-digikala'),
            self::WAITING_FOR_GATEWAY   => __('waiting for gateway', 'buy-with-digikala'),
            self::EXPIRED               => __('expired', 'buy-with-digikala'),
            self::CANCELLED             => __('cancelled', 'buy-with-digikala'),
            self::PAID_BY_USER          => __('paid by user', 'buy-with-digikala'),
            self::FAILED_TO_PAY         => __('failed to pay', 'buy-with-digikala'),
            self::VERIFIED_BY_MERCHANT  => __('verified by merchant', 'buy-with-digikala'),
            self::FAILED_TO_VERIFY      => __('failed to verify by merchant', 'buy-with-digikala'),
            self::FAILED_BY_MERCHANT    => __('failed by merchant', 'buy-with-digikala'),
            self::CANCELLED_BY_MERCHANT => __('cancelled by merchant', 'buy-with-digikala'),
            self::REFUND_BY_MERCHANT    => __('refunded by merchant', 'buy-with-digikala'),
        ];
    }

    /**
     * دریافت متن وضعیت بر اساس کد
     */
    public static function label(int $status): string
    {
        $labels = self::labels();
        return $labels[$status] ?? __('unknown', 'buy-with-digikala');
    }

    /**
     * بررسی اینکه وضعیت معتبر هست یا نه
     */
    public static function isValid(int $status): bool
    {
        return array_key_exists($status, self::labels());
    }
}
