@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | |
21 | 21 | public function __construct(StateMachineBuilder $smb = null) |
22 | 22 | { |
23 | - if ($smb != null) |
|
24 | - $this->smb = $smb->from(); |
|
23 | + if ($smb != null) { |
|
24 | + $this->smb = $smb->from(); |
|
25 | + } |
|
25 | 26 | |
26 | 27 | if (!empty($this->smb)) { |
27 | 28 | // StateEnum::CURRENT_STATE => [ EventEnum::ON_EVENT => [ NEXT_STATE, ClosureOrFunctionsArray ] ], |
@@ -73,8 +74,9 @@ discard block |
||
73 | 74 | $arrayActions = $execAction; |
74 | 75 | foreach ($arrayActions as $exec_action => $action) { |
75 | 76 | if( $this->in_actions_key($exec_action) ){ |
76 | - if( $action === null ) |
|
77 | - continue; |
|
77 | + if( $action === null ) { |
|
78 | + continue; |
|
79 | + } |
|
78 | 80 | $this->argumentMustBeClosureOrFail($action); |
79 | 81 | } |
80 | 82 | $this->sm[$currentState][$currentEvent][$exec_action] = $action; |
@@ -156,8 +158,9 @@ discard block |
||
156 | 158 | if( array_key_exists(self::$EXEC_GUARD, $transition) ){ |
157 | 159 | $guard = $transition[self::$EXEC_GUARD]; |
158 | 160 | if ($guard) { |
159 | - if (($guard)($this) === false) |
|
160 | - $wasGuarded = true; |
|
161 | + if (($guard)($this) === false) { |
|
162 | + $wasGuarded = true; |
|
163 | + } |
|
161 | 164 | } |
162 | 165 | } |
163 | 166 | return $wasGuarded; |
@@ -207,8 +210,9 @@ discard block |
||
207 | 210 | |
208 | 211 | $data_out = []; |
209 | 212 | foreach ($data as $value) { |
210 | - if ($this->in_actions_key($value)) |
|
211 | - continue; |
|
213 | + if ($this->in_actions_key($value)) { |
|
214 | + continue; |
|
215 | + } |
|
212 | 216 | $data_out[$value] = $this->sm[$this->currentState][$this->currentEvent][$value]; |
213 | 217 | } |
214 | 218 | |
@@ -264,8 +268,9 @@ discard block |
||
264 | 268 | |
265 | 269 | private function setCurrentStateIfThisIsInitialState($state): void |
266 | 270 | { |
267 | - if( $this->currentState == null) |
|
268 | - $this->currentState = $state; |
|
271 | + if( $this->currentState == null) { |
|
272 | + $this->currentState = $state; |
|
273 | + } |
|
269 | 274 | } |
270 | 275 | |
271 | 276 | private function argumentIsValidOrFail($arg): void |
@@ -276,31 +281,36 @@ discard block |
||
276 | 281 | |
277 | 282 | private function argumentIsNotNullOrFail($arg): void |
278 | 283 | { |
279 | - if( $arg === null ) |
|
280 | - throw new \InvalidArgumentException("Null is not an valid argument"); |
|
284 | + if( $arg === null ) { |
|
285 | + throw new \InvalidArgumentException("Null is not an valid argument"); |
|
286 | + } |
|
281 | 287 | } |
282 | 288 | |
283 | 289 | private function argumentIsNotBlankOrFail($arg): void |
284 | 290 | { |
285 | - if( trim($arg) === "" ) |
|
286 | - throw new \InvalidArgumentException("Blank is not an valid argument"); |
|
291 | + if( trim($arg) === "" ) { |
|
292 | + throw new \InvalidArgumentException("Blank is not an valid argument"); |
|
293 | + } |
|
287 | 294 | } |
288 | 295 | |
289 | 296 | private function eventMustExistOrFail($event) |
290 | 297 | { |
291 | - if( !( isset($this->sm[$this->currentState][$event]) ) ) |
|
292 | - throw new \InvalidArgumentException("Unexpected event '{$event}' on '{$this->currentState}' state"); |
|
298 | + if( !( isset($this->sm[$this->currentState][$event]) ) ) { |
|
299 | + throw new \InvalidArgumentException("Unexpected event '{$event}' on '{$this->currentState}' state"); |
|
300 | + } |
|
293 | 301 | } |
294 | 302 | |
295 | 303 | private function stateMustExistOrFail($state) |
296 | 304 | { |
297 | - if( ! isset($this->sm[$state]) ) |
|
298 | - throw new \InvalidArgumentException("Event '{$this->currentEvent}' fired to unadded '{$state}' state"); |
|
305 | + if( ! isset($this->sm[$state]) ) { |
|
306 | + throw new \InvalidArgumentException("Event '{$this->currentEvent}' fired to unadded '{$state}' state"); |
|
307 | + } |
|
299 | 308 | } |
300 | 309 | |
301 | 310 | private function argumentMustBeClosureOrFail($action): void |
302 | 311 | { |
303 | - if( !($action instanceof \Closure) ) |
|
304 | - throw new \InvalidArgumentException('execAction argument must be Closure or array'); |
|
312 | + if( !($action instanceof \Closure) ) { |
|
313 | + throw new \InvalidArgumentException('execAction argument must be Closure or array'); |
|
314 | + } |
|
305 | 315 | } |
306 | 316 | } |