36 lines
832 B
PHP
36 lines
832 B
PHP
<?php
|
|
|
|
namespace App\Provisioning;
|
|
|
|
/**
|
|
* The outcome a step returns to the runner: advance to the next step, retry
|
|
* this step after a delay, or fail the run.
|
|
*/
|
|
final class StepResult
|
|
{
|
|
public const ADVANCE = 'advance';
|
|
public const RETRY = 'retry';
|
|
public const FAIL = 'fail';
|
|
|
|
private function __construct(
|
|
public readonly string $type,
|
|
public readonly int $afterSeconds = 0,
|
|
public readonly string $reason = '',
|
|
) {}
|
|
|
|
public static function advance(): self
|
|
{
|
|
return new self(self::ADVANCE);
|
|
}
|
|
|
|
public static function retry(int $afterSeconds, string $reason): self
|
|
{
|
|
return new self(self::RETRY, $afterSeconds, $reason);
|
|
}
|
|
|
|
public static function fail(string $reason): self
|
|
{
|
|
return new self(self::FAIL, 0, $reason);
|
|
}
|
|
}
|