1 | <?php |
||
13 | class StateTransitionFailed extends Exception |
||
14 | { |
||
15 | /** |
||
16 | * The default exception message that will be used if none is provided |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | const MESSAGE = 'Error occurred while executing a state transition'; |
||
21 | |||
22 | /** |
||
23 | * The context object shared across state transitions |
||
24 | * |
||
25 | * @var Context |
||
26 | */ |
||
27 | private $context; |
||
28 | |||
29 | /** |
||
30 | * The stateful object |
||
31 | * |
||
32 | * @var Stateful |
||
33 | */ |
||
34 | private $object; |
||
35 | |||
36 | /** |
||
37 | * The input that triggered the state transition |
||
38 | * |
||
39 | * @var Input |
||
40 | */ |
||
41 | private $input; |
||
42 | |||
43 | /** |
||
44 | * The state that would have been achived, had the transition succeeded |
||
45 | * |
||
46 | * @var State |
||
47 | */ |
||
48 | private $nextState; |
||
49 | |||
50 | /** |
||
51 | * Constructor |
||
52 | * |
||
53 | * @param Input $input |
||
54 | * @param Stateful $object |
||
55 | * @param Context $context |
||
56 | * @param State $nextState |
||
57 | * @param \Exception $previous (Optional) |
||
58 | */ |
||
59 | 2 | public function __construct( |
|
80 | |||
81 | /** |
||
82 | * Returns the shared context object |
||
83 | * |
||
84 | * @return Context |
||
85 | */ |
||
86 | 1 | public function getContext() : Context |
|
90 | |||
91 | /** |
||
92 | * Returns the input that triggered the state transition |
||
93 | * |
||
94 | * @return Input |
||
95 | */ |
||
96 | 1 | public function getInput() : Input |
|
100 | |||
101 | 1 | public function getNextState() : State |
|
105 | |||
106 | /** |
||
107 | * Returns the stateful object |
||
108 | * |
||
109 | * @return Stateful |
||
110 | */ |
||
111 | 1 | public function getObject() : Stateful |
|
115 | } |
||
116 |