<?php

declare(strict_types=1);

final class MyronLicenseStatus
{
    public const MISSING = 'missing';
    public const ACTIVE = 'active';
    public const GRACE = 'grace';
    public const EXPIRED = 'expired';
    public const DISABLED = 'disabled';
    public const CANCELED = 'canceled';
    public const PAYMENT_FAILED = 'payment_failed';
    public const INVALID = 'invalid';
    public const STALE = 'stale';
    public const UNREGISTERED = 'unregistered';

    /**
     * @return list<string>
     */
    public static function known(): array
    {
        return [
            self::MISSING,
            self::ACTIVE,
            self::GRACE,
            self::EXPIRED,
            self::DISABLED,
            self::CANCELED,
            self::PAYMENT_FAILED,
            self::INVALID,
            self::STALE,
            self::UNREGISTERED,
        ];
    }

    public static function normalize(string $status): string
    {
        $normalized = strtolower(trim($status));
        return in_array($normalized, self::known(), true) ? $normalized : self::INVALID;
    }

    public static function allowsRuntime(string $status): bool
    {
        return in_array(self::normalize($status), [self::ACTIVE, self::GRACE, self::PAYMENT_FAILED, self::STALE, self::UNREGISTERED], true);
    }
}
