@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | if ($smb != null) |
24 | 24 | $this->smb = $smb->from(); |
25 | 25 | |
26 | - if (!empty($this->smb)) { |
|
26 | + if ( ! empty($this->smb)) { |
|
27 | 27 | // StateEnum::CURRENT_STATE => [ EventEnum::ON_EVENT => [ NEXT_STATE, ClosureOrFunctionsArray ] ], |
28 | 28 | foreach ($this->smb as $state => $transition) { |
29 | 29 | $this->addState($state); |
@@ -66,20 +66,20 @@ discard block |
||
66 | 66 | |
67 | 67 | $this->setCurrentStateIfThisIsInitialState($currentState); |
68 | 68 | |
69 | - if( $execAction === null ){ |
|
70 | - $this->sm[$currentState][$currentEvent] = [ self::$NEXT_STATE => $nextState ]; |
|
69 | + if ($execAction === null) { |
|
70 | + $this->sm[$currentState][$currentEvent] = [self::$NEXT_STATE => $nextState]; |
|
71 | 71 | } elseif (is_array($execAction)) { |
72 | - $this->sm[$currentState][$currentEvent] = [ self::$NEXT_STATE => $nextState ]; |
|
72 | + $this->sm[$currentState][$currentEvent] = [self::$NEXT_STATE => $nextState]; |
|
73 | 73 | $arrayActions = $execAction; |
74 | 74 | foreach ($arrayActions as $exec_action => $action) { |
75 | - if( $this->in_actions_key($exec_action) ){ |
|
76 | - if( $action === null ) |
|
75 | + if ($this->in_actions_key($exec_action)) { |
|
76 | + if ($action === null) |
|
77 | 77 | continue; |
78 | 78 | $this->argumentMustBeClosureOrFail($action); |
79 | 79 | } |
80 | 80 | $this->sm[$currentState][$currentEvent][$exec_action] = $action; |
81 | 81 | } |
82 | - } elseif($execAction instanceof \Closure) { |
|
82 | + } elseif ($execAction instanceof \Closure) { |
|
83 | 83 | $this->sm[$currentState][$currentEvent] = [ |
84 | 84 | self::$NEXT_STATE => $nextState, |
85 | 85 | self::$EXEC_ACTION => $execAction |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | $wasGuarded = $this->execGuard($transition); |
131 | 131 | |
132 | - if (!$wasGuarded) { |
|
132 | + if ( ! $wasGuarded) { |
|
133 | 133 | $this->execAction(self::$EXEC_BEFORE, $transition); |
134 | 134 | $this->execAction(self::$EXEC_ACTION, $transition); |
135 | 135 | $this->execAction(self::$EXEC_AFTER, $transition); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | private function execGuard($transition): bool |
154 | 154 | { |
155 | 155 | $wasGuarded = false; |
156 | - if( array_key_exists(self::$EXEC_GUARD, $transition) ){ |
|
156 | + if (array_key_exists(self::$EXEC_GUARD, $transition)) { |
|
157 | 157 | $guard = $transition[self::$EXEC_GUARD]; |
158 | 158 | if ($guard) { |
159 | 159 | if (($guard)($this) === false) |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | { |
178 | 178 | $this->argumentIsValidOrFail($event); |
179 | 179 | |
180 | - try{ |
|
180 | + try { |
|
181 | 181 | $this->eventMustExistOrFail($event); |
182 | - } catch(\InvalidArgumentException $e){ |
|
182 | + } catch (\InvalidArgumentException $e) { |
|
183 | 183 | return false; |
184 | 184 | } |
185 | 185 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | |
265 | 265 | private function setCurrentStateIfThisIsInitialState($state): void |
266 | 266 | { |
267 | - if( $this->currentState == null) |
|
267 | + if ($this->currentState == null) |
|
268 | 268 | $this->currentState = $state; |
269 | 269 | } |
270 | 270 | |
@@ -276,31 +276,31 @@ discard block |
||
276 | 276 | |
277 | 277 | private function argumentIsNotNullOrFail($arg): void |
278 | 278 | { |
279 | - if( $arg === null ) |
|
279 | + if ($arg === null) |
|
280 | 280 | throw new \InvalidArgumentException("Null is not an valid argument"); |
281 | 281 | } |
282 | 282 | |
283 | 283 | private function argumentIsNotBlankOrFail($arg): void |
284 | 284 | { |
285 | - if( trim($arg) === "" ) |
|
285 | + if (trim($arg) === "") |
|
286 | 286 | throw new \InvalidArgumentException("Blank is not an valid argument"); |
287 | 287 | } |
288 | 288 | |
289 | 289 | private function eventMustExistOrFail($event) |
290 | 290 | { |
291 | - if( !( isset($this->sm[$this->currentState][$event]) ) ) |
|
291 | + if ( ! (isset($this->sm[$this->currentState][$event]))) |
|
292 | 292 | throw new \InvalidArgumentException("Unexpected event '{$event}' on '{$this->currentState}' state"); |
293 | 293 | } |
294 | 294 | |
295 | 295 | private function stateMustExistOrFail($state) |
296 | 296 | { |
297 | - if( ! isset($this->sm[$state]) ) |
|
297 | + if ( ! isset($this->sm[$state])) |
|
298 | 298 | throw new \InvalidArgumentException("Event '{$this->currentEvent}' fired to unadded '{$state}' state"); |
299 | 299 | } |
300 | 300 | |
301 | 301 | private function argumentMustBeClosureOrFail($action): void |
302 | 302 | { |
303 | - if( !($action instanceof \Closure) ) |
|
303 | + if ( ! ($action instanceof \Closure)) |
|
304 | 304 | throw new \InvalidArgumentException('execAction argument must be Closure or array'); |
305 | 305 | } |
306 | 306 | } |