@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | |
24 | 24 | public function __construct(StateMachineBuilder $smb = null) |
25 | 25 | { |
26 | - if( $smb != null ) |
|
27 | - $this->smb = $smb->from(); |
|
26 | + if( $smb != null ) { |
|
27 | + $this->smb = $smb->from(); |
|
28 | + } |
|
28 | 29 | |
29 | 30 | if( ! empty($this->smb) ){ |
30 | 31 | // StateEnum::CURRENT_STATE => [ EventEnum::ON_EVENT => [ NEXT_STATE, ActionClosureOrFunction ] ], |
@@ -40,8 +41,9 @@ discard block |
||
40 | 41 | } |
41 | 42 | |
42 | 43 | public function to(){ |
43 | - if( $this->smb == null ) |
|
44 | - return; |
|
44 | + if( $this->smb == null ) { |
|
45 | + return; |
|
46 | + } |
|
45 | 47 | |
46 | 48 | $this->smb->to($this->getMachineToArray()); |
47 | 49 | } |
@@ -133,8 +135,9 @@ discard block |
||
133 | 135 | if( array_key_exists(self::EXEC_GUARD, $transition) ){ |
134 | 136 | $guard = $transition[self::EXEC_GUARD]; |
135 | 137 | if ($guard) { |
136 | - if (($guard)($this) === false) |
|
137 | - $wasGuarded = true; |
|
138 | + if (($guard)($this) === false) { |
|
139 | + $wasGuarded = true; |
|
140 | + } |
|
138 | 141 | } |
139 | 142 | } |
140 | 143 | if ( ! $wasGuarded) { |
@@ -189,8 +192,9 @@ discard block |
||
189 | 192 | $can = true; |
190 | 193 | $guard = $transition[self::EXEC_GUARD]; |
191 | 194 | if( $guard ){ |
192 | - if( ($guard)($this) === false ) |
|
193 | - $can = false; |
|
195 | + if( ($guard)($this) === false ) { |
|
196 | + $can = false; |
|
197 | + } |
|
194 | 198 | } |
195 | 199 | return $can; |
196 | 200 | } |
@@ -237,26 +241,30 @@ discard block |
||
237 | 241 | |
238 | 242 | private function argumentIsNotNullOrFail($arg): void |
239 | 243 | { |
240 | - if( $arg === null ) |
|
241 | - throw new \InvalidArgumentException("Null is not an valid argument"); |
|
244 | + if( $arg === null ) { |
|
245 | + throw new \InvalidArgumentException("Null is not an valid argument"); |
|
246 | + } |
|
242 | 247 | } |
243 | 248 | |
244 | 249 | private function argumentIsNotBlankOrFail($arg): void |
245 | 250 | { |
246 | - if( trim($arg) === "" ) |
|
247 | - throw new \InvalidArgumentException("Blank is not an valid argument"); |
|
251 | + if( trim($arg) === "" ) { |
|
252 | + throw new \InvalidArgumentException("Blank is not an valid argument"); |
|
253 | + } |
|
248 | 254 | } |
249 | 255 | |
250 | 256 | private function eventMustExistOrFail($event) |
251 | 257 | { |
252 | - if( !( isset($this->sm[$this->currentState][$event]) ) ) |
|
253 | - throw new \InvalidArgumentException("Unexpected event '{$event}' on '{$this->currentState}' state"); |
|
258 | + if( !( isset($this->sm[$this->currentState][$event]) ) ) { |
|
259 | + throw new \InvalidArgumentException("Unexpected event '{$event}' on '{$this->currentState}' state"); |
|
260 | + } |
|
254 | 261 | } |
255 | 262 | |
256 | 263 | private function stateMustExistOrFail($state) |
257 | 264 | { |
258 | - if( ! isset($this->sm[$state]) ) |
|
259 | - throw new \InvalidArgumentException("Event '{$this->currentEvent}' fired an unexpected '{$state}' state"); |
|
265 | + if( ! isset($this->sm[$state]) ) { |
|
266 | + throw new \InvalidArgumentException("Event '{$this->currentEvent}' fired an unexpected '{$state}' state"); |
|
267 | + } |
|
260 | 268 | } |
261 | 269 | |
262 | 270 | private function setCurrentStateIfThisIsInitialState($state): void |