@@ -24,8 +24,9 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function __construct(StateMachineBuilder $smb = null) |
| 26 | 26 | { |
| 27 | - if ($smb != null) |
|
| 28 | - $this->smb = $smb->from(); |
|
| 27 | + if ($smb != null) { |
|
| 28 | + $this->smb = $smb->from(); |
|
| 29 | + } |
|
| 29 | 30 | |
| 30 | 31 | if (!empty($this->smb)) { |
| 31 | 32 | // StateEnum::CURRENT_STATE => [ EventEnum::ON_EVENT => [ NEXT_STATE, ClosureOrFunctionsArray ] ], |
@@ -151,8 +152,9 @@ discard block |
||
| 151 | 152 | if( array_key_exists(self::EXEC_GUARD, $transition) ){ |
| 152 | 153 | $guard = $transition[self::EXEC_GUARD]; |
| 153 | 154 | if ($guard) { |
| 154 | - if (($guard)($this) === false) |
|
| 155 | - $wasGuarded = true; |
|
| 155 | + if (($guard)($this) === false) { |
|
| 156 | + $wasGuarded = true; |
|
| 157 | + } |
|
| 156 | 158 | } |
| 157 | 159 | } |
| 158 | 160 | return $wasGuarded; |
@@ -237,26 +239,30 @@ discard block |
||
| 237 | 239 | |
| 238 | 240 | private function argumentIsNotNullOrFail($arg): void |
| 239 | 241 | { |
| 240 | - if( $arg === null ) |
|
| 241 | - throw new \InvalidArgumentException("Null is not an valid argument"); |
|
| 242 | + if( $arg === null ) { |
|
| 243 | + throw new \InvalidArgumentException("Null is not an valid argument"); |
|
| 244 | + } |
|
| 242 | 245 | } |
| 243 | 246 | |
| 244 | 247 | private function argumentIsNotBlankOrFail($arg): void |
| 245 | 248 | { |
| 246 | - if( trim($arg) === "" ) |
|
| 247 | - throw new \InvalidArgumentException("Blank is not an valid argument"); |
|
| 249 | + if( trim($arg) === "" ) { |
|
| 250 | + throw new \InvalidArgumentException("Blank is not an valid argument"); |
|
| 251 | + } |
|
| 248 | 252 | } |
| 249 | 253 | |
| 250 | 254 | private function eventMustExistOrFail($event) |
| 251 | 255 | { |
| 252 | - if( !( isset($this->sm[$this->currentState][$event]) ) ) |
|
| 253 | - throw new \InvalidArgumentException("Unexpected event '{$event}' on '{$this->currentState}' state"); |
|
| 256 | + if( !( isset($this->sm[$this->currentState][$event]) ) ) { |
|
| 257 | + throw new \InvalidArgumentException("Unexpected event '{$event}' on '{$this->currentState}' state"); |
|
| 258 | + } |
|
| 254 | 259 | } |
| 255 | 260 | |
| 256 | 261 | private function stateMustExistOrFail($state) |
| 257 | 262 | { |
| 258 | - if( ! isset($this->sm[$state]) ) |
|
| 259 | - throw new \InvalidArgumentException("Event '{$this->currentEvent}' fired to unadded '{$state}' state"); |
|
| 263 | + if( ! isset($this->sm[$state]) ) { |
|
| 264 | + throw new \InvalidArgumentException("Event '{$this->currentEvent}' fired to unadded '{$state}' state"); |
|
| 265 | + } |
|
| 260 | 266 | } |
| 261 | 267 | |
| 262 | 268 | private function setCurrentStateIfThisIsInitialState($state): void |