31 lines
843 B
PHP
31 lines
843 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\OperationalControls;
|
|
|
|
use RuntimeException;
|
|
|
|
final class OperationalControlBlockedException extends RuntimeException
|
|
{
|
|
private function __construct(
|
|
public readonly OperationalControlDecision $decision,
|
|
public readonly string $actionLabel,
|
|
) {
|
|
$message = trim($decision->reasonText ?? '');
|
|
|
|
parent::__construct($message !== ''
|
|
? sprintf('%s is currently paused. %s', $actionLabel, $message)
|
|
: sprintf('%s is currently paused.', $actionLabel));
|
|
}
|
|
|
|
public static function forDecision(OperationalControlDecision $decision, string $actionLabel): self
|
|
{
|
|
return new self($decision, $actionLabel);
|
|
}
|
|
|
|
public function title(): string
|
|
{
|
|
return sprintf('%s paused', $this->actionLabel);
|
|
}
|
|
} |