<?php

namespace App\Services\Ssh;

final class CommandResult
{
    public function __construct(
        public readonly int $exitCode,
        public readonly string $stdout = '',
        public readonly string $stderr = '',
    ) {}

    public function ok(): bool
    {
        return $this->exitCode === 0;
    }

    public static function success(string $stdout = ''): self
    {
        return new self(0, $stdout);
    }

    public static function failure(int $exitCode = 1, string $stderr = ''): self
    {
        return new self($exitCode, '', $stderr);
    }
}
