<?php

declare(strict_types=1);

namespace App\Enums\SupportCenter;

enum HostSystemUpdateExecutionStatus: string
{
    case Pending = 'pending';
    case Prechecking = 'prechecking';
    case Ready = 'ready';
    case Running = 'running';
    case Completed = 'completed';
    case Failed = 'failed';
    case Cancelled = 'cancelled';
    case RollbackRequired = 'rollback_required';
    case RollingBack = 'rolling_back';
    case RolledBack = 'rolled_back';
    case RollbackFailed = 'rollback_failed';

    /**
     * @return list<string>
     */
    public static function activeValues(): array
    {
        return [
            self::Pending->value,
            self::Prechecking->value,
            self::Ready->value,
            self::Running->value,
            self::RollbackRequired->value,
            self::RollingBack->value,
        ];
    }

    public function isTerminal(): bool
    {
        return in_array($this, [
            self::Completed,
            self::Failed,
            self::Cancelled,
            self::RolledBack,
            self::RollbackFailed,
        ], true);
    }
}
