Passed
Push — master ( af11e6...9ff364 )
by Sebastian
03:46
created
src/Mailcode/Commands.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     {
48 48
         static $ids = array();
49 49
         
50
-        if(empty($ids)) {
50
+        if (empty($ids)) {
51 51
             $ids = FileHelper::createFileFinder(__DIR__.'/Commands/Command')
52 52
             ->getPHPClassNames();
53 53
         }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function getAll() : array
67 67
     {
68
-        if(!empty($this->commands)) {
68
+        if (!empty($this->commands)) {
69 69
             return $this->commands;
70 70
         }
71 71
         
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         
74 74
         $result = array();
75 75
         
76
-        foreach($ids as $id) 
76
+        foreach ($ids as $id) 
77 77
         {
78 78
             $result[] = $this->getDummyCommand($id);
79 79
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     {
99 99
         static $instances = array();
100 100
         
101
-        if(!isset($instances[$id])) 
101
+        if (!isset($instances[$id])) 
102 102
         {
103 103
             $instances[$id] = $this->createCommand($id, '__dummy', '', '');
104 104
         }
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
     {
120 120
         $items = $this->getAll();
121 121
         
122
-        foreach($items as $item) 
122
+        foreach ($items as $item) 
123 123
         {
124
-            if($item->getName() === $name) {
124
+            if ($item->getName() === $name) {
125 125
                 return $item->getID();
126 126
             }
127 127
         }
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
     {
154 154
         $items = $this->getAll();
155 155
         
156
-        foreach($items as $item)
156
+        foreach ($items as $item)
157 157
         {
158
-            if($item->getName() === $name) {
158
+            if ($item->getName() === $name) {
159 159
                 return true;
160 160
             }
161 161
         }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     {
168 168
         $class = $this->resolveClassName($id, $type);
169 169
         
170
-        if(!class_exists($class))
170
+        if (!class_exists($class))
171 171
         {
172 172
             throw new Mailcode_Exception(
173 173
                 'No such command',
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         
183 183
         $command = new $class($type, $params, $matchedString);
184 184
 
185
-        if($command instanceof Mailcode_Commands_Command)
185
+        if ($command instanceof Mailcode_Commands_Command)
186 186
         {
187 187
             return $command;
188 188
         }
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
         
204 204
         $dummy = $this->getDummyCommand($id);
205 205
         
206
-        if($dummy->supportsType())
206
+        if ($dummy->supportsType())
207 207
         {
208
-            if(empty($type))
208
+            if (empty($type))
209 209
             {
210 210
                 $type = $dummy->getDefaultType();
211 211
             }
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
      */
244 244
     private function getDummyCommand(string $id) : Mailcode_Commands_Command
245 245
     {
246
-        if(isset(self::$dummyCommands[$id])) {
246
+        if (isset(self::$dummyCommands[$id])) {
247 247
             return self::$dummyCommands[$id];
248 248
         }
249 249
 
250 250
         $class = 'Mailcode\Mailcode_Commands_Command_'.$id;
251 251
         $cmd = new $class('__dummy');
252 252
 
253
-        if($cmd instanceof Mailcode_Commands_Command)
253
+        if ($cmd instanceof Mailcode_Commands_Command)
254 254
         {
255 255
             self::$dummyCommands[$id] = $cmd;
256 256
             return $cmd;
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
         $result = array();
276 276
         $commands = $this->getAll();
277 277
 
278
-        foreach($commands as $command)
278
+        foreach ($commands as $command)
279 279
         {
280
-            if($command instanceof Mailcode_Interfaces_Commands_ProtectedContent)
280
+            if ($command instanceof Mailcode_Interfaces_Commands_ProtectedContent)
281 281
             {
282 282
                 $result[] = $command;
283 283
             }
Please login to merge, or discard this patch.
src/Mailcode/Collection.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function addCommand(Mailcode_Commands_Command $command) : Mailcode_Collection
47 47
     {
48
-        if($this->finalized)
48
+        if ($this->finalized)
49 49
         {
50 50
             throw new Mailcode_Exception(
51 51
                 'Cannot add commands to a finalized collection',
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
     {
88 88
         $keep = array();
89 89
 
90
-        foreach($this->commands as $existing)
90
+        foreach ($this->commands as $existing)
91 91
         {
92
-            if($existing !== $command)
92
+            if ($existing !== $command)
93 93
             {
94 94
                 $keep[] = $existing;
95 95
             }
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 
127 127
         $hashes = array();
128 128
         
129
-        foreach($this->commands as $command)
129
+        foreach ($this->commands as $command)
130 130
         {
131 131
             $hash = $command->getHash();
132 132
             
133
-            if(!isset($hashes[$hash]))
133
+            if (!isset($hashes[$hash]))
134 134
             {
135 135
                 $hashes[$hash] = $command;
136 136
             }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function addCommands(array $commands) : Mailcode_Collection
150 150
     {
151
-        foreach($commands as $command)
151
+        foreach ($commands as $command)
152 152
         {
153 153
             $this->addCommand($command);
154 154
         }
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
         $collection = new Mailcode_Variables_Collection_Regular();
173 173
         
174
-        foreach($this->commands as $command)
174
+        foreach ($this->commands as $command)
175 175
         {
176 176
             $collection->mergeWith($command->getVariables());
177 177
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     {
212 212
         $this->validate();
213 213
 
214
-        if(isset($this->validationResult))
214
+        if (isset($this->validationResult))
215 215
         {
216 216
             return $this->validationResult;
217 217
         }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
     private function validate() : void
227 227
     {
228
-        if(isset($this->validationResult) || $this->validating)
228
+        if (isset($this->validationResult) || $this->validating)
229 229
         {
230 230
             return;
231 231
         }
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
     {
246 246
         $errors = $this->getErrors();
247 247
         
248
-        foreach($errors as $error)
248
+        foreach ($errors as $error)
249 249
         {
250
-            if($error->getCode() === $code)
250
+            if ($error->getCode() === $code)
251 251
             {
252 252
                 return true;
253 253
             }
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
         $errors = $this->errors;
284 284
 
285
-        if(!$result->isValid())
285
+        if (!$result->isValid())
286 286
         {
287 287
             $errors[] = new Mailcode_Collection_Error_Message(
288 288
                 '',
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
     {
299 299
         $errors = $this->getErrors();
300 300
 
301
-        if(!empty($errors))
301
+        if (!empty($errors))
302 302
         {
303 303
             return array_shift($errors);
304 304
         }
@@ -319,11 +319,11 @@  discard block
 block discarded – undo
319 319
 
320 320
     private function validateNesting() : void
321 321
     {
322
-        foreach($this->commands as $command)
322
+        foreach ($this->commands as $command)
323 323
         {
324 324
             $command->validateNesting();
325 325
 
326
-            if(!$command->isValid()) {
326
+            if (!$command->isValid()) {
327 327
                 $this->addInvalidCommand($command);
328 328
             }
329 329
         }
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
     {
401 401
         $commands = $this->getCommands();
402 402
         
403
-        if(!empty($commands))
403
+        if (!empty($commands))
404 404
         {
405 405
             return array_shift($commands);
406 406
         }
@@ -432,16 +432,16 @@  discard block
 block discarded – undo
432 432
      */
433 433
     private function pruneProtectedContentCommands() : void
434 434
     {
435
-        if(!$this->isValid())
435
+        if (!$this->isValid())
436 436
         {
437 437
             return;
438 438
         }
439 439
 
440 440
         $keep = array();
441 441
 
442
-        foreach($this->commands as $command)
442
+        foreach ($this->commands as $command)
443 443
         {
444
-            if(!$command->hasContentParent())
444
+            if (!$command->hasContentParent())
445 445
             {
446 446
                 $keep[] = $command;
447 447
             }
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
         $errors = $this->getErrors();
459 459
         $result = array();
460 460
 
461
-        foreach($errors as $error)
461
+        foreach ($errors as $error)
462 462
         {
463 463
             $result[] = $error->getCode();
464 464
         }
Please login to merge, or discard this patch.