Passed
Push — master ( 7a5dd1...cfa4be )
by Javier
03:16
created
src/StateMachine.php 1 patch
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,8 +23,9 @@  discard block
 block discarded – undo
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 ] ],
@@ -135,8 +136,9 @@  discard block
 block discarded – undo
135 136
         if( array_key_exists(self::EXEC_GUARD, $transition) ){
136 137
             $guard = $transition[self::EXEC_GUARD];
137 138
             if ($guard) {
138
-                if (($guard)($this) === false)
139
-                    $wasGuarded = true;
139
+                if (($guard)($this) === false) {
140
+                                    $wasGuarded = true;
141
+                }
140 142
             }
141 143
         }
142 144
         if ( ! $wasGuarded) {
@@ -199,8 +201,9 @@  discard block
 block discarded – undo
199 201
         $can = true;
200 202
         $guard = $transition[self::EXEC_GUARD];
201 203
         if( $guard ){
202
-            if( ($guard)($this) === false )
203
-                $can = false;
204
+            if( ($guard)($this) === false ) {
205
+                            $can = false;
206
+            }
204 207
         }
205 208
         return $can;
206 209
     }
@@ -247,26 +250,30 @@  discard block
 block discarded – undo
247 250
 
248 251
     private function argumentIsNotNullOrFail($arg): void
249 252
     {
250
-        if( $arg === null )
251
-            throw new \InvalidArgumentException("Null is not an valid argument");
253
+        if( $arg === null ) {
254
+                    throw new \InvalidArgumentException("Null is not an valid argument");
255
+        }
252 256
     }
253 257
 
254 258
     private function argumentIsNotBlankOrFail($arg): void
255 259
     {
256
-        if( trim($arg) === "" )
257
-            throw new \InvalidArgumentException("Blank is not an valid argument");
260
+        if( trim($arg) === "" ) {
261
+                    throw new \InvalidArgumentException("Blank is not an valid argument");
262
+        }
258 263
     }
259 264
 
260 265
     private function eventMustExistOrFail($event)
261 266
     {
262
-        if( !( isset($this->sm[$this->currentState][$event]) ) )
263
-            throw new \InvalidArgumentException("Unexpected event '{$event}' on '{$this->currentState}' state");
267
+        if( !( isset($this->sm[$this->currentState][$event]) ) ) {
268
+                    throw new \InvalidArgumentException("Unexpected event '{$event}' on '{$this->currentState}' state");
269
+        }
264 270
     }
265 271
 
266 272
     private function stateMustExistOrFail($state)
267 273
     {
268
-        if( ! isset($this->sm[$state]) )
269
-            throw new \InvalidArgumentException("Event '{$this->currentEvent}' fired to unadded '{$state}' state");
274
+        if( ! isset($this->sm[$state]) ) {
275
+                    throw new \InvalidArgumentException("Event '{$this->currentEvent}' fired to unadded '{$state}' state");
276
+        }
270 277
     }
271 278
 
272 279
     private function setCurrentStateIfThisIsInitialState($state): void
Please login to merge, or discard this patch.