Passed
Push — master ( 6d02c4...011dd0 )
by Javier
02:30
created
src/StateMachine.php 2 patches
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@  discard block
 block discarded – undo
20 20
 	
21 21
 	public function __construct(StateMachineBuilder $smb = null)
22 22
     {
23
-        if(  $smb != null )
24
-            $sm = $smb->__invoke();
23
+        if(  $smb != null ) {
24
+                    $sm = $smb->__invoke();
25
+        }
25 26
 
26 27
         if( ! empty($sm) ){
27 28
             // StateEnum::CURRENT_STATE => [ EventEnum::ON_EVENT => [ StateEnum::NEXT_STATE_2, ActionClosureOrFunction ]  ],
@@ -149,26 +150,30 @@  discard block
 block discarded – undo
149 150
 
150 151
     private function argumentIsNotNullOrFail($arg): void
151 152
     {
152
-        if( $arg === null )
153
-            throw new \InvalidArgumentException("Null is not an valid argument");
153
+        if( $arg === null ) {
154
+                    throw new \InvalidArgumentException("Null is not an valid argument");
155
+        }
154 156
     }
155 157
 
156 158
     private function argumentIsNotBlankOrFail($arg): void
157 159
     {
158
-        if( trim($arg) === "" )
159
-            throw new \InvalidArgumentException("Blank is not an valid argument");
160
+        if( trim($arg) === "" ) {
161
+                    throw new \InvalidArgumentException("Blank is not an valid argument");
162
+        }
160 163
     }
161 164
 
162 165
     private function eventMustExistOrFail($event)
163 166
     {
164
-        if( !( isset($this->sm[$this->currentState][$event]) || isset($this->commonTransition[$event]) ) )
165
-            throw new \InvalidArgumentException("Unexpected event {$event} on {$this->currentState} state");
167
+        if( !( isset($this->sm[$this->currentState][$event]) || isset($this->commonTransition[$event]) ) ) {
168
+                    throw new \InvalidArgumentException("Unexpected event {$event} on {$this->currentState} state");
169
+        }
166 170
     }
167 171
 
168 172
     private function stateMustExistOrFail($state)
169 173
     {
170
-        if( ! isset($this->sm[$this->currentState]) )
171
-            throw new \InvalidArgumentException("Event {$this->currentEvent} fired an unexpected {$this->currentState} state");
174
+        if( ! isset($this->sm[$this->currentState]) ) {
175
+                    throw new \InvalidArgumentException("Event {$this->currentEvent} fired an unexpected {$this->currentState} state");
176
+        }
172 177
     }
173 178
 
174 179
     private function setCurrentStateIfThisIsInitialState($state): void
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@  discard block
 block discarded – undo
8 8
     private const NEXT_STATE = 0;
9 9
     private const EXEC_ACTION = 1;
10 10
     
11
-	protected $sm = array();
12
-	protected $currentState = null;
11
+    protected $sm = array();
12
+    protected $currentState = null;
13 13
     protected $currentEvent = null;
14 14
     protected $nextState = null;
15 15
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     private $eventsQueued = [];
19 19
     private $commonTransition = [];
20 20
 	
21
-	public function __construct(StateMachineBuilder $smb = null)
21
+    public function __construct(StateMachineBuilder $smb = null)
22 22
     {
23 23
         if(  $smb != null )
24 24
             $sm = $smb->__invoke();
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
     public function addState($state)
42 42
     {
43
-	    $this->argumentIsValidOrFail($state);
43
+        $this->argumentIsValidOrFail($state);
44 44
 
45 45
         $this->setCurrentStateIfThisIsInitialState($state);
46 46
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         $this->commonTransition[$currentEvent] = [
73 73
                                                     self::NEXT_STATE => $nextState,
74 74
                                                     self::EXEC_ACTION => $execAction
75
-                                                 ];
75
+                                                    ];
76 76
         return $this;
77 77
     }
78 78
 
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
         }
179 179
     }
180 180
 
181
-	public function dumpStates(){
182
-		var_dump(array_keys($this->sm));
183
-	}
181
+    public function dumpStates(){
182
+        var_dump(array_keys($this->sm));
183
+    }
184 184
 	
185
-	public function dumpEvents(){
186
-		var_dump($this->sm);
187
-	}
185
+    public function dumpEvents(){
186
+        var_dump($this->sm);
187
+    }
188 188
 }
Please login to merge, or discard this patch.