<?php

declare(strict_types=1);

namespace App\Enums\SupportCenter;

/**
 * 基于环境诊断的推荐系统更新方式（面向更新中心展示）。
 */
enum HostSystemUpdateRecommendedMethod: string
{
    case BrowserAvailable = 'browser_available';
    case BrowserRisky = 'browser_risky';
    case BrowserBlockedUseTerminal = 'browser_blocked_use_terminal';

    public function label(): string
    {
        return (string) __('dberp.system_update_center.recommended_method.labels.'.$this->value);
    }

    public function badgeColor(): string
    {
        return match ($this) {
            self::BrowserAvailable => 'success',
            self::BrowserRisky => 'warning',
            self::BrowserBlockedUseTerminal => 'danger',
        };
    }

    public function allowsBrowserUpdate(): bool
    {
        return $this === self::BrowserAvailable || $this === self::BrowserRisky;
    }

    public function prefersTerminalUpdate(): bool
    {
        return $this === self::BrowserBlockedUseTerminal;
    }
}
