Spec 432: Exchange PowerShell production runner boundary and runtime gate. Validation: php artisan test --filter=Spec432 --compact; ./vendor/bin/pint --dirty --test --format agent; git diff --check. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #499
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\TenantConfiguration;
|
|
|
|
final readonly class ExchangePowerShellProcessResult
|
|
{
|
|
private function __construct(
|
|
public int $exitCode,
|
|
public string $stdout,
|
|
public string $stderr,
|
|
public bool $timedOut,
|
|
public int $durationMs,
|
|
public ?string $exceptionClass = null,
|
|
) {}
|
|
|
|
public static function completed(int $exitCode, string $stdout = '', string $stderr = '', int $durationMs = 0): self
|
|
{
|
|
return new self(
|
|
exitCode: $exitCode,
|
|
stdout: $stdout,
|
|
stderr: $stderr,
|
|
timedOut: false,
|
|
durationMs: max(0, $durationMs),
|
|
);
|
|
}
|
|
|
|
public static function timedOut(int $durationMs = 0): self
|
|
{
|
|
return new self(
|
|
exitCode: 124,
|
|
stdout: '',
|
|
stderr: '',
|
|
timedOut: true,
|
|
durationMs: max(0, $durationMs),
|
|
);
|
|
}
|
|
|
|
public static function exception(string $exceptionClass, int $durationMs = 0): self
|
|
{
|
|
return new self(
|
|
exitCode: 1,
|
|
stdout: '',
|
|
stderr: '',
|
|
timedOut: false,
|
|
durationMs: max(0, $durationMs),
|
|
exceptionClass: $exceptionClass,
|
|
);
|
|
}
|
|
}
|