65c1b5fb75
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
31 lines
625 B
PHP
31 lines
625 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXC\Application\Execution;
|
|
|
|
final readonly class ExecutionOutcome
|
|
{
|
|
private function __construct(
|
|
public bool $successful,
|
|
public mixed $result = null,
|
|
public ?\Throwable $error = null,
|
|
) {
|
|
}
|
|
|
|
public static function success(mixed $result = null): self
|
|
{
|
|
return new self(true, $result);
|
|
}
|
|
|
|
public static function failure(\Throwable $error, mixed $result = null): self
|
|
{
|
|
return new self(false, $result, $error);
|
|
}
|
|
|
|
public static function incomplete(): self
|
|
{
|
|
return new self(false);
|
|
}
|
|
}
|