Passed
Push — master ( d31021...33110a )
by Sebastian
64:00
created
src/Mailcode/Factory.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,13 +94,15 @@
 block discarded – undo
94 94
         return $cmd;
95 95
     }
96 96
     
97
-    public static function else() : Mailcode_Commands_Command_Else
97
+    public static function else {
98
+        () : Mailcode_Commands_Command_Else
98 99
     {
99 100
         $cmd = new Mailcode_Commands_Command_Else(
100 101
             '', // type,
101 102
             '', // params,
102 103
             '{else}'
103 104
         );
105
+    }
104 106
         
105 107
         self::_checkCommand($cmd);
106 108
         
Please login to merge, or discard this patch.
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -24,17 +24,17 @@  discard block
 block discarded – undo
24 24
     
25 25
     const ERROR_UNEXPECTED_COMMAND_TYPE = 50002;
26 26
     
27
-   /**
28
-    * @var Mailcode_Renderer
29
-    */
27
+    /**
28
+     * @var Mailcode_Renderer
29
+     */
30 30
     protected static $renderer;
31 31
     
32
-   /**
33
-    * Creates a ShowVariable command.
34
-    * 
35
-    * @param string $variableName A variable name, with or without the $ sign prepended.
36
-    * @return Mailcode_Commands_Command_ShowVariable
37
-    */
32
+    /**
33
+     * Creates a ShowVariable command.
34
+     * 
35
+     * @param string $variableName A variable name, with or without the $ sign prepended.
36
+     * @return Mailcode_Commands_Command_ShowVariable
37
+     */
38 38
     public static function showVar(string $variableName) : Mailcode_Commands_Command_ShowVariable
39 39
     {
40 40
         $variableName = self::_filterVariableName($variableName);
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
         return $cmd;
51 51
     }
52 52
     
53
-   /**
54
-    * Creates a SetVariable command.
55
-    * 
56
-    * @param string $variableName A variable name, with or without the $ sign prepended.
57
-    * @param string $value
58
-    * @param bool $quoteValue Whether to treat the value as a string literal, and add quotes to it.
59
-    * @return Mailcode_Commands_Command_SetVariable
60
-    * @throws Mailcode_Factory_Exception
61
-    * 
62
-    * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED
63
-    */
53
+    /**
54
+     * Creates a SetVariable command.
55
+     * 
56
+     * @param string $variableName A variable name, with or without the $ sign prepended.
57
+     * @param string $value
58
+     * @param bool $quoteValue Whether to treat the value as a string literal, and add quotes to it.
59
+     * @return Mailcode_Commands_Command_SetVariable
60
+     * @throws Mailcode_Factory_Exception
61
+     * 
62
+     * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED
63
+     */
64 64
     public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable
65 65
     {
66 66
         $variableName = self::_filterVariableName($variableName);
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
         return $cmd;
84 84
     }
85 85
     
86
-   /**
87
-    * Like setVar(), but treats the value as a string literal
88
-    * and automatically adds quotes to it.
89
-    * 
90
-    * @param string $variableName
91
-    * @param string $value
92
-    * @return Mailcode_Commands_Command_SetVariable
93
-    */
86
+    /**
87
+     * Like setVar(), but treats the value as a string literal
88
+     * and automatically adds quotes to it.
89
+     * 
90
+     * @param string $variableName
91
+     * @param string $value
92
+     * @return Mailcode_Commands_Command_SetVariable
93
+     */
94 94
     public static function setVarString(string $variableName, string $value) : Mailcode_Commands_Command_SetVariable
95 95
     {
96 96
         return self::setVar($variableName, $value, true);
@@ -355,12 +355,12 @@  discard block
 block discarded – undo
355 355
         return '$'.ltrim($name, '$');
356 356
     }
357 357
     
358
-   /**
359
-    * Quotes a string literal: adds the quotes, and escapes any quotes already present in it.
360
-    * 
361
-    * @param string $string
362
-    * @return string
363
-    */
358
+    /**
359
+     * Quotes a string literal: adds the quotes, and escapes any quotes already present in it.
360
+     * 
361
+     * @param string $string
362
+     * @return string
363
+     */
364 364
     protected static function _quoteString(string $string) : string
365 365
     {
366 366
         return '"'.str_replace('"', '\"', $string).'"';
@@ -393,23 +393,23 @@  discard block
 block discarded – undo
393 393
         );
394 394
     }
395 395
     
396
-   /**
397
-    * Creates a renderer instance, which can be used to easily
398
-    * create and convert commands to strings.
399
-    * 
400
-    * @return Mailcode_Renderer
401
-    */
396
+    /**
397
+     * Creates a renderer instance, which can be used to easily
398
+     * create and convert commands to strings.
399
+     * 
400
+     * @return Mailcode_Renderer
401
+     */
402 402
     public static function createRenderer() : Mailcode_Renderer
403 403
     {
404 404
         return new Mailcode_Renderer();
405 405
     }
406 406
     
407
-   /**
408
-    * Creates a printer instance, which works like the renderer,
409
-    * but outputs the generated strings to standard output.
410
-    * 
411
-    * @return Mailcode_Printer
412
-    */
407
+    /**
408
+     * Creates a printer instance, which works like the renderer,
409
+     * but outputs the generated strings to standard output.
410
+     * 
411
+     * @return Mailcode_Printer
412
+     */
413 413
     public static function createPrinter() : Mailcode_Printer
414 414
     {
415 415
         return new Mailcode_Printer();
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
     * 
62 62
     * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED
63 63
     */
64
-    public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable
64
+    public static function setVar(string $variableName, string $value, bool $quoteValue = true) : Mailcode_Commands_Command_SetVariable
65 65
     {
66 66
         $variableName = self::_filterVariableName($variableName);
67 67
         
68
-        if($quoteValue)
68
+        if ($quoteValue)
69 69
         {
70 70
             $value = self::_quoteString($value);
71 71
         }
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
         return $cmd;
139 139
     }
140 140
     
141
-    protected static function _buildIf(string $cmd, string $condition, string $type='') : Mailcode_Commands_Command
141
+    protected static function _buildIf(string $cmd, string $condition, string $type = '') : Mailcode_Commands_Command
142 142
     {
143 143
         $stringType = $type;
144 144
         
145
-        if(!empty($type))
145
+        if (!empty($type))
146 146
         {
147 147
             $stringType = ' '.$type;
148 148
         }
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
         return $cmd;
166 166
     }
167 167
   
168
-    protected static function _buildIfVar(string $cmd, string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command
168
+    protected static function _buildIfVar(string $cmd, string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command
169 169
     {
170
-        if($quoteValue)
170
+        if ($quoteValue)
171 171
         {
172 172
             $value = self::_quoteString($value);
173 173
         }
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
         return self::_buildIf($cmd, $condition, 'variable');
183 183
     }
184 184
     
185
-    public static function if(string $condition, string $type='') : Mailcode_Commands_Command_If
185
+    public static function if (string $condition, string $type = '') : Mailcode_Commands_Command_If
186 186
     {
187 187
         $cmd = self::_buildIf('If', $condition, $type);
188 188
         
189
-        if($cmd instanceof Mailcode_Commands_Command_If)
189
+        if ($cmd instanceof Mailcode_Commands_Command_If)
190 190
         {
191 191
             return $cmd;
192 192
         }
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
         throw self::_exceptionUnexpectedType($cmd);
195 195
     }
196 196
     
197
-    public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If
197
+    public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If
198 198
     {
199 199
         $cmd = self::_buildIfVar('If', $variable, $operand, $value, $quoteValue);
200 200
         
201
-        if($cmd instanceof Mailcode_Commands_Command_If)
201
+        if ($cmd instanceof Mailcode_Commands_Command_If)
202 202
         {
203 203
             return $cmd;
204 204
         }
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     {
211 211
         $cmd = self::_buildIfVar('If', $variable, $operand, $value, true);
212 212
         
213
-        if($cmd instanceof Mailcode_Commands_Command_If)
213
+        if ($cmd instanceof Mailcode_Commands_Command_If)
214 214
         {
215 215
             return $cmd;
216 216
         }
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
         throw self::_exceptionUnexpectedType($cmd);
219 219
     }
220 220
     
221
-    public static function ifVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If
221
+    public static function ifVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If
222 222
     {
223 223
         $cmd = self::_buildIfVar('If', $variable, '==', $value, $quoteValue);
224 224
         
225
-        if($cmd instanceof Mailcode_Commands_Command_If)
225
+        if ($cmd instanceof Mailcode_Commands_Command_If)
226 226
         {
227 227
             return $cmd;
228 228
         }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
     {
235 235
         $cmd = self::_buildIfVar('If', $variable, '==', $value, true);
236 236
         
237
-        if($cmd instanceof Mailcode_Commands_Command_If)
237
+        if ($cmd instanceof Mailcode_Commands_Command_If)
238 238
         {
239 239
             return $cmd;
240 240
         }
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
         throw self::_exceptionUnexpectedType($cmd);
243 243
     }
244 244
     
245
-    public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If
245
+    public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If
246 246
     {
247 247
         $cmd = self::_buildIfVar('If', $variable, '!=', $value, $quoteValue);
248 248
         
249
-        if($cmd instanceof Mailcode_Commands_Command_If)
249
+        if ($cmd instanceof Mailcode_Commands_Command_If)
250 250
         {
251 251
             return $cmd;
252 252
         }
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     {
259 259
         $cmd = self::_buildIfVar('If', $variable, '!=', $value, true);
260 260
         
261
-        if($cmd instanceof Mailcode_Commands_Command_If)
261
+        if ($cmd instanceof Mailcode_Commands_Command_If)
262 262
         {
263 263
             return $cmd;
264 264
         }
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
         throw self::_exceptionUnexpectedType($cmd);
267 267
     }
268 268
     
269
-    public static function elseIf(string $condition, string $type='') : Mailcode_Commands_Command_ElseIf
269
+    public static function elseIf (string $condition, string $type = '') : Mailcode_Commands_Command_ElseIf
270 270
     {
271 271
         $cmd = self::_buildIf('ElseIf', $condition, $type);
272 272
         
273
-        if($cmd instanceof Mailcode_Commands_Command_ElseIf)
273
+        if ($cmd instanceof Mailcode_Commands_Command_ElseIf)
274 274
         {
275 275
             return $cmd;
276 276
         }
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
         throw self::_exceptionUnexpectedType($cmd);
279 279
     }
280 280
     
281
-    public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf
281
+    public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf
282 282
     {
283 283
         $cmd = self::_buildIfVar('ElseIf', $variable, $operand, $value, $quoteValue);
284 284
         
285
-        if($cmd instanceof Mailcode_Commands_Command_ElseIf)
285
+        if ($cmd instanceof Mailcode_Commands_Command_ElseIf)
286 286
         {
287 287
             return $cmd;
288 288
         }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
     {
295 295
         $cmd = self::_buildIfVar('ElseIf', $variable, $operand, $value, true);
296 296
         
297
-        if($cmd instanceof Mailcode_Commands_Command_ElseIf)
297
+        if ($cmd instanceof Mailcode_Commands_Command_ElseIf)
298 298
         {
299 299
             return $cmd;
300 300
         }
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
         throw self::_exceptionUnexpectedType($cmd);
303 303
     }
304 304
     
305
-    public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf
305
+    public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf
306 306
     {
307 307
         $cmd = self::_buildIfVar('ElseIf', $variable, '==', $value, $quoteValue);
308 308
         
309
-        if($cmd instanceof Mailcode_Commands_Command_ElseIf)
309
+        if ($cmd instanceof Mailcode_Commands_Command_ElseIf)
310 310
         {
311 311
             return $cmd;
312 312
         }
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
     {
319 319
         $cmd = self::_buildIfVar('ElseIf', $variable, '==', $value, true);
320 320
         
321
-        if($cmd instanceof Mailcode_Commands_Command_ElseIf)
321
+        if ($cmd instanceof Mailcode_Commands_Command_ElseIf)
322 322
         {
323 323
             return $cmd;
324 324
         }
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
         throw self::_exceptionUnexpectedType($cmd);
327 327
     }
328 328
     
329
-    public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf
329
+    public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf
330 330
     {
331 331
         $cmd = self::_buildIfVar('ElseIf', $variable, '!=', $value, $quoteValue);
332 332
         
333
-        if($cmd instanceof Mailcode_Commands_Command_ElseIf)
333
+        if ($cmd instanceof Mailcode_Commands_Command_ElseIf)
334 334
         {
335 335
             return $cmd;
336 336
         }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
     {
343 343
         $cmd = self::_buildIfVar('ElseIf', $variable, '!=', $value, true);
344 344
         
345
-        if($cmd instanceof Mailcode_Commands_Command_ElseIf)
345
+        if ($cmd instanceof Mailcode_Commands_Command_ElseIf)
346 346
         {
347 347
             return $cmd;
348 348
         }
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
     
369 369
     protected static function _checkCommand(Mailcode_Commands_Command $command) : void
370 370
     {
371
-        if($command->isValid())
371
+        if ($command->isValid())
372 372
         {
373 373
             return;
374 374
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/SetVariable.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     {
59 59
         $variable = $this->params->getInfo()->getVariableByIndex(0);
60 60
         
61
-        if($variable)
61
+        if ($variable)
62 62
         {
63 63
             return $variable->getVariable();
64 64
         }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     
87 87
     protected function validateSyntax_assignment() : void
88 88
     {
89
-        if($this->params->getInfo()->isVariableAssignment())
89
+        if ($this->params->getInfo()->isVariableAssignment())
90 90
         {
91 91
             return;
92 92
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/Comment.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     protected function init() : void
24 24
     {
25 25
         // automatically quote the parameters, since comments don't require any.
26
-        if(!strstr($this->paramsString, '"'))
26
+        if (!strstr($this->paramsString, '"'))
27 27
         {
28 28
             $this->paramsString = '"'.$this->paramsString.'"';
29 29
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowVariable.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
     
25 25
     const VALIDATION_VARIABLE_COUNT_MISMATCH = 48401;
26 26
     
27
-   /**
28
-    * @var Mailcode_Variables_Variable|NULL
29
-    */
27
+    /**
28
+     * @var Mailcode_Variables_Variable|NULL
29
+     */
30 30
     protected $variable;
31 31
     
32 32
     public function getName() : string
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
         return true;
50 50
     }
51 51
     
52
-   /**
53
-    * Retrieves the variable to show.
54
-    * 
55
-    * NOTE: Only available once the command has been
56
-    * validated. Always use isValid() first.
57
-    * 
58
-    * @throws Mailcode_Exception
59
-    * @return Mailcode_Variables_Variable
60
-    */
52
+    /**
53
+     * Retrieves the variable to show.
54
+     * 
55
+     * NOTE: Only available once the command has been
56
+     * validated. Always use isValid() first.
57
+     * 
58
+     * @throws Mailcode_Exception
59
+     * @return Mailcode_Variables_Variable
60
+     */
61 61
     public function getVariable() : Mailcode_Variables_Variable
62 62
     {
63 63
         $this->validate();
@@ -74,15 +74,15 @@  discard block
 block discarded – undo
74 74
         );
75 75
     }
76 76
     
77
-   /**
78
-    * Retrieves the full name of the variable to show.
79
-    * 
80
-    * NOTE: Only available once the command has been
81
-    * validated. Always use isValid() first.
82
-    * 
83
-    * @throws Mailcode_Exception
84
-    * @return string
85
-    */
77
+    /**
78
+     * Retrieves the full name of the variable to show.
79
+     * 
80
+     * NOTE: Only available once the command has been
81
+     * validated. Always use isValid() first.
82
+     * 
83
+     * @throws Mailcode_Exception
84
+     * @return string
85
+     */
86 86
     public function getVariableName() : string
87 87
     {
88 88
         return $this->getVariable()->getFullName();
@@ -90,19 +90,19 @@  discard block
 block discarded – undo
90 90
 
91 91
     protected function validateSyntax_require_variable() : void
92 92
     {
93
-         $vars = $this->getVariables()->getGroupedByName();
94
-         $amount = count($vars);
93
+            $vars = $this->getVariables()->getGroupedByName();
94
+            $amount = count($vars);
95 95
          
96
-         if($amount === 1)
97
-         {
98
-             $this->variable = array_pop($vars);
99
-             return;
100
-         }
96
+            if($amount === 1)
97
+            {
98
+                $this->variable = array_pop($vars);
99
+                return;
100
+            }
101 101
          
102
-         $this->validationResult->makeError(
102
+            $this->validationResult->makeError(
103 103
             t('Command has %1$s variables, %2$s expected.', $amount, 1),
104 104
             self::VALIDATION_VARIABLE_COUNT_MISMATCH
105
-         );
105
+            );
106 106
     }
107 107
     
108 108
     protected function getValidations() : array
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $this->validate();
64 64
         
65
-        if(isset($this->variable))
65
+        if (isset($this->variable))
66 66
         {
67 67
             return $this->variable;
68 68
         }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
          $vars = $this->getVariables()->getGroupedByName();
94 94
          $amount = count($vars);
95 95
          
96
-         if($amount === 1)
96
+         if ($amount === 1)
97 97
          {
98 98
              $this->variable = array_pop($vars);
99 99
              return;
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/If.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 {
23 23
     const VALIDATION_VARIABLE_COUNT_MISMATCH = 49201;
24 24
     
25
-   /**
26
-    * @var Mailcode_Variables_Variable
27
-    */
25
+    /**
26
+     * @var Mailcode_Variables_Variable
27
+     */
28 28
     protected $variable;
29 29
     
30 30
     public function getName() : string
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
         return $this->type === 'variable';
58 58
     }
59 59
     
60
-   /**
61
-    * Available only if the command is of type "variable".
62
-    * 
63
-    * @return Mailcode_Variables_Variable|NULL
64
-    */
60
+    /**
61
+     * Available only if the command is of type "variable".
62
+     * 
63
+     * @return Mailcode_Variables_Variable|NULL
64
+     */
65 65
     public function getVariable() : ?Mailcode_Variables_Variable
66 66
     {
67 67
         if(isset($this->variable))
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     */
65 65
     public function getVariable() : ?Mailcode_Variables_Variable
66 66
     {
67
-        if(isset($this->variable))
67
+        if (isset($this->variable))
68 68
         {
69 69
             return $this->variable;
70 70
         }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $amount = $this->getVariables()->countVariables();
78 78
         
79
-        if($amount >= 1)
79
+        if ($amount >= 1)
80 80
         {
81 81
             return;
82 82
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     {
92 92
         $validations = array();
93 93
         
94
-        if($this->getType() === 'variable')
94
+        if ($this->getType() === 'variable')
95 95
         {
96 96
             $validations[] = 'require_variable';
97 97
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/For.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
         $keyword = $info->getKeywordByIndex(1);
63 63
         $container = $info->getVariableByIndex(2);
64 64
         
65
-        if($variable && $keyword && $container && $keyword->isForIn())
65
+        if ($variable && $keyword && $container && $keyword->isForIn())
66 66
         {
67 67
             return;
68 68
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Highlighter.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,19 +20,19 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class Mailcode_Commands_Highlighter
22 22
 {
23
-   /**
24
-    * @var Mailcode_Commands_Command
25
-    */
23
+    /**
24
+     * @var Mailcode_Commands_Command
25
+     */
26 26
     protected $command;
27 27
     
28
-   /**
29
-    * @var string[]
30
-    */
28
+    /**
29
+     * @var string[]
30
+     */
31 31
     protected $parts = array();
32 32
     
33 33
     public function __construct(Mailcode_Commands_Command $command)
34 34
     {
35
-       $this->command = $command;
35
+        $this->command = $command;
36 36
     }
37 37
     
38 38
     public function highlight() : string
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
         }
69 69
     }
70 70
     
71
-   /**
72
-    * @param string[] $classes
73
-    * @param string $content
74
-    * @return string
75
-    */
71
+    /**
72
+     * @param string[] $classes
73
+     * @param string $content
74
+     * @return string
75
+     */
76 76
     protected function renderTag(array $classes, string $content) : string
77 77
     {
78 78
         $parts = array();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     {
52 52
         $this->parts[] = $this->renderTag(array('command-name'), $this->command->getName());
53 53
         
54
-        if($this->command->hasType())
54
+        if ($this->command->hasType())
55 55
         {
56 56
             $this->parts[] = ' '.$this->renderTag(array('command-type'), $this->command->getType());
57 57
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     
63 63
     protected function appendParams() : void
64 64
     {
65
-        if($this->command->hasParameters())
65
+        if ($this->command->hasParameters())
66 66
         {
67 67
             $this->parts[] = ' '.$this->renderTag(array('params'), $this->command->getParamsString());
68 68
         }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     {
78 78
         $parts = array();
79 79
         
80
-        foreach($classes as $class)
80
+        foreach ($classes as $class)
81 81
         {
82 82
             $parts[] = 'mailcode-'.$class;
83 83
         }
Please login to merge, or discard this patch.
src/Mailcode/Variables/Variable.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -32,34 +32,34 @@
 block discarded – undo
32 32
     const VALIDATION_ERROR_PATH_UNDERSCORE = 48203;
33 33
     const VALIDATION_ERROR_NAME_UNDERSCORE = 48204;
34 34
     
35
-   /**
36
-    * @var string
37
-    */
35
+    /**
36
+     * @var string
37
+     */
38 38
     protected $path;
39 39
     
40
-   /**
41
-    * @var string
42
-    */
40
+    /**
41
+     * @var string
42
+     */
43 43
     protected $name;
44 44
     
45
-   /**
46
-    * @var string
47
-    */
45
+    /**
46
+     * @var string
47
+     */
48 48
     protected $matchedText;
49 49
     
50
-   /**
51
-    * @var string
52
-    */
50
+    /**
51
+     * @var string
52
+     */
53 53
     protected $hash = '';
54 54
     
55
-   /**
56
-    * @var OperationResult
57
-    */
55
+    /**
56
+     * @var OperationResult
57
+     */
58 58
     protected $validationResult = null;
59 59
     
60
-   /**
61
-    * @var array<string>
62
-    */
60
+    /**
61
+     * @var array<string>
62
+     */
63 63
     protected $validations = array(
64 64
         'number_path',
65 65
         'number_name',
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     
77 77
     public function getFullName() : string
78 78
     {
79
-        if(empty($this->path))
79
+        if (empty($this->path))
80 80
         {
81 81
             return '$'.$this->name;
82 82
         }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     
102 102
     public function getHash() : string
103 103
     {
104
-        if(empty($this->hash))
104
+        if (empty($this->hash))
105 105
         {
106 106
             $this->hash = md5($this->matchedText);
107 107
         }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     
117 117
     public function getValidationResult() : OperationResult
118 118
     {
119
-        if(isset($this->validationResult))
119
+        if (isset($this->validationResult))
120 120
         {
121 121
             return $this->validationResult;
122 122
         }
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 
131 131
     protected function validate() : void
132 132
     {
133
-        foreach($this->validations as $validation)
133
+        foreach ($this->validations as $validation)
134 134
         {
135 135
             $method = 'validate_'.$validation;
136 136
             
137
-            if(!method_exists($this, $method))
137
+            if (!method_exists($this, $method))
138 138
             {
139 139
                 throw new Mailcode_Exception(
140 140
                     'Unknown validation method',
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
             
150 150
             $this->$method();
151 151
             
152
-            if(!$this->validationResult->isValid())
152
+            if (!$this->validationResult->isValid())
153 153
             {
154 154
                 return;
155 155
             }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
     
179 179
     protected function validateNumber(string $value, int $errorCode) : void
180 180
     {
181
-        if(!is_numeric(substr($value, 0, 1)))
181
+        if (!is_numeric(substr($value, 0, 1)))
182 182
         {
183 183
             return;
184 184
         }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     protected function validateUnderscore(string $value, int $errorCode) : void
197 197
     {
198 198
         // allow empty paths
199
-        if(empty($value))
199
+        if (empty($value))
200 200
         {
201 201
             return;
202 202
         }
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         $length = strlen($value);
205 205
         
206 206
         // trimming underscores does not change the length: no underscores at start or end of string.
207
-        if(strlen(trim($value, '_')) == $length)
207
+        if (strlen(trim($value, '_')) == $length)
208 208
         {
209 209
             return;
210 210
         }
Please login to merge, or discard this patch.
src/Mailcode/Variables/Collection.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
  */
21 21
 abstract class Mailcode_Variables_Collection
22 22
 {
23
-   /**
24
-    * @var Mailcode_Variables_Variable[]
25
-    */
23
+    /**
24
+     * @var Mailcode_Variables_Variable[]
25
+     */
26 26
     protected $variables = array();
27 27
     
28 28
     public function __construct()
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
         return count($this->variables);
53 53
     }
54 54
     
55
-   /**
56
-    * Checks whether the collection contains a variable with the specified name.
57
-    * 
58
-    * @param string $fullName The variable name, with or without $ sign.
59
-    * @return bool
60
-    */
55
+    /**
56
+     * Checks whether the collection contains a variable with the specified name.
57
+     * 
58
+     * @param string $fullName The variable name, with or without $ sign.
59
+     * @return bool
60
+     */
61 61
     public function hasVariableName(string $fullName) : bool
62 62
     {
63 63
         $fullName = $this->fixName($fullName);
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
         return false;
74 74
     }
75 75
     
76
-   /**
77
-    * Retrieves a collection of all variable instances for
78
-    * the specified name (there can be several with differing
79
-    * matched texts because of spacing).
80
-    * 
81
-    * @param string $fullName
82
-    * @return Mailcode_Variables_Collection
83
-    */
76
+    /**
77
+     * Retrieves a collection of all variable instances for
78
+     * the specified name (there can be several with differing
79
+     * matched texts because of spacing).
80
+     * 
81
+     * @param string $fullName
82
+     * @return Mailcode_Variables_Collection
83
+     */
84 84
     public function getByFullName(string $fullName) : Mailcode_Variables_Collection
85 85
     {
86 86
         $fullName = $this->fixName($fullName);
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
         return $collection;
99 99
     }
100 100
     
101
-   /**
102
-    * Prepends the $ sign to a variable name if it does not have it.
103
-    * 
104
-    * @param string $fullName
105
-    * @return string
106
-    */
101
+    /**
102
+     * Prepends the $ sign to a variable name if it does not have it.
103
+     * 
104
+     * @param string $fullName
105
+     * @return string
106
+     */
107 107
     protected function fixName(string $fullName) : string
108 108
     {
109 109
         if(substr($fullName, 0, 1) === '$')
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
         return '$'.$fullName;
115 115
     }
116 116
     
117
-   /**
118
-    * Retrieves all variables, grouped by their hash - meaning
119
-    * unique matched strings.
120
-    * 
121
-    * @return Mailcode_Variables_Variable[]
122
-    */
117
+    /**
118
+     * Retrieves all variables, grouped by their hash - meaning
119
+     * unique matched strings.
120
+     * 
121
+     * @return Mailcode_Variables_Variable[]
122
+     */
123 123
     public function getGroupedByHash()
124 124
     {
125 125
         $entries = array();
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
         return $this->sortVariables($entries);
133 133
     }
134 134
     
135
-   /**
136
-    * Retrieves all variables, grouped by their name. 
137
-    * 
138
-    * @return Mailcode_Variables_Variable[]
139
-    */
135
+    /**
136
+     * Retrieves all variables, grouped by their name. 
137
+     * 
138
+     * @return Mailcode_Variables_Variable[]
139
+     */
140 140
     public function getGroupedByName()
141 141
     {
142 142
         $entries = array();
@@ -149,19 +149,19 @@  discard block
 block discarded – undo
149 149
         return $this->sortVariables($entries);
150 150
     }
151 151
     
152
-   /**
153
-    * Retrieves all variables, in the order they were addded.
154
-    * @return \Mailcode\Mailcode_Variables_Variable[]
155
-    */
152
+    /**
153
+     * Retrieves all variables, in the order they were addded.
154
+     * @return \Mailcode\Mailcode_Variables_Variable[]
155
+     */
156 156
     public function getAll()
157 157
     {
158 158
         return $this->variables;
159 159
     }
160 160
     
161
-   /**
162
-    * Retrieves the full names of the variables that are present in the collection.
163
-    * @return string[]
164
-    */
161
+    /**
162
+     * Retrieves the full names of the variables that are present in the collection.
163
+     * @return string[]
164
+     */
165 165
     public function getNames() : array
166 166
     {
167 167
         $result = array();
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
         return $result;
180 180
     }
181 181
     
182
-   /**
183
-    * Takes a list of variables and sorts them, throwing away
184
-    * the source array's keys.
185
-    * 
186
-    * @param Mailcode_Variables_Variable[] $entries
187
-    * @return Mailcode_Variables_Variable[]
188
-    */
182
+    /**
183
+     * Takes a list of variables and sorts them, throwing away
184
+     * the source array's keys.
185
+     * 
186
+     * @param Mailcode_Variables_Variable[] $entries
187
+     * @return Mailcode_Variables_Variable[]
188
+     */
189 189
     protected function sortVariables(array $entries)
190 190
     {
191 191
         $result = array_values($entries);
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
         return $result;
199 199
     }
200 200
 
201
-   /**
202
-    *  Merges the variables collection with the target collection
203
-    *  by inheriting all that collection's variables.
204
-    *  
205
-    * @param Mailcode_Variables_Collection $collection
206
-    * @return Mailcode_Variables_Collection
207
-    */
201
+    /**
202
+     *  Merges the variables collection with the target collection
203
+     *  by inheriting all that collection's variables.
204
+     *  
205
+     * @param Mailcode_Variables_Collection $collection
206
+     * @return Mailcode_Variables_Collection
207
+     */
208 208
     public function mergeWith(Mailcode_Variables_Collection $collection) : Mailcode_Variables_Collection
209 209
     {
210 210
         $variables = $collection->getGroupedByHash();
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $fullName = $this->fixName($fullName);
64 64
         
65
-        foreach($this->variables as $variable)
65
+        foreach ($this->variables as $variable)
66 66
         {
67
-            if($variable->getFullName() === $fullName)
67
+            if ($variable->getFullName() === $fullName)
68 68
             {
69 69
                 return true;
70 70
             }
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
         
88 88
         $collection = new Mailcode_Variables_Collection_Regular();
89 89
         
90
-        foreach($this->variables as $variable)
90
+        foreach ($this->variables as $variable)
91 91
         {
92
-            if($variable->getFullName() === $fullName)
92
+            if ($variable->getFullName() === $fullName)
93 93
             {
94 94
                 $collection->add($variable);
95 95
             }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     */
107 107
     protected function fixName(string $fullName) : string
108 108
     {
109
-        if(substr($fullName, 0, 1) === '$')
109
+        if (substr($fullName, 0, 1) === '$')
110 110
         {
111 111
             return $fullName;
112 112
         }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     {
125 125
         $entries = array();
126 126
         
127
-        foreach($this->variables as $variable)
127
+        foreach ($this->variables as $variable)
128 128
         {
129 129
             $entries[$variable->getHash()] = $variable;
130 130
         }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     {
142 142
         $entries = array();
143 143
         
144
-        foreach($this->variables as $variable)
144
+        foreach ($this->variables as $variable)
145 145
         {
146 146
             $entries[$variable->getFullName()] = $variable;
147 147
         }
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
     {
167 167
         $result = array();
168 168
         
169
-        foreach($this->variables as $variable)
169
+        foreach ($this->variables as $variable)
170 170
         {
171 171
             $name = $variable->getFullName();
172 172
             
173
-            if(!in_array($name, $result))
173
+            if (!in_array($name, $result))
174 174
             {
175 175
                 $result[] = $name;
176 176
             }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     {
210 210
         $variables = $collection->getGroupedByHash();
211 211
         
212
-        foreach($variables as $variable)
212
+        foreach ($variables as $variable)
213 213
         {
214 214
             $this->add($variable);
215 215
         }
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     {
222 222
         $variables = $this->getAll();
223 223
         
224
-        if(!empty($variables))
224
+        if (!empty($variables))
225 225
         {
226 226
             return array_shift($variables);
227 227
         }
Please login to merge, or discard this patch.