-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionBehaviorNotSatisfied.php
More file actions
69 lines (59 loc) · 1.73 KB
/
Copy pathActionBehaviorNotSatisfied.php
File metadata and controls
69 lines (59 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* @author enea dhack <contact@vaened.dev>
* @link https://vaened.dev DevFolio
*/
declare(strict_types=1);
namespace Vaened\DeltaOrchestrator\Exceptions;
use Closure;
use Throwable;
use Vaened\DeltaOrchestrator\ActionFailure;
use Vaened\DeltaOrchestrator\Bindings\Behavior;
use Vaened\DeltaOrchestrator\ExecutionResult;
use Vaened\DeltaOrchestrator\Field;
final class ActionBehaviorNotSatisfied extends DeltaOrchestratorException implements ActionFailure
{
public function __construct(
private readonly Behavior $behavior,
private readonly Field $field,
private readonly ?string $actionDescription = null,
private readonly ?ExecutionResult $progressUntilFailure = null,
private readonly ?Closure $failureFactory = null,
)
{
parent::__construct(
$this->actionDescription !== null
? "Action behavior was not satisfied: $this->actionDescription."
: 'Action behavior was not satisfied.',
);
}
public function actionDescription(): ?string
{
return $this->actionDescription;
}
public function behavior(): Behavior
{
return $this->behavior;
}
public function field(): Field
{
return $this->field;
}
public function progressUntilFailure(): ?ExecutionResult
{
return $this->progressUntilFailure;
}
/**
* @return (Closure(ActionFailure): Throwable)|null
*/
public function failureFactory(): ?Closure
{
return $this->failureFactory;
}
public function rethrow(): never
{
throw $this->failureFactory !== null
? ($this->failureFactory)($this)
: $this;
}
}