<?php

declare(strict_types=1);

namespace App\Services\SupportCenter;

use App\Models\HostSystemUpdateExecution;

/**
 * CLI 系统更新执行结果。
 */
final readonly class HostSystemUpdateCliRunResult
{
    public function __construct(
        public bool $succeeded,
        public string $message,
        public ?HostSystemUpdateExecution $execution = null,
        public ?string $recoverySuggestion = null,
    ) {}

    public static function success(HostSystemUpdateExecution $execution, string $message): self
    {
        return new self(
            succeeded: true,
            message: $message,
            execution: $execution,
        );
    }

    public static function failure(
        string $message,
        ?HostSystemUpdateExecution $execution = null,
        ?string $recoverySuggestion = null,
    ): self {
        return new self(
            succeeded: false,
            message: $message,
            execution: $execution,
            recoverySuggestion: $recoverySuggestion,
        );
    }
}
