Passed
Push — master ( 689687...b6ef8f )
by Sebastian
02:28
created
src/Mailcode/Parser/Statement.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -29,24 +29,24 @@  discard block
 block discarded – undo
29 29
     
30 30
     const VALIDATION_UNQUOTED_STRING_LITERALS = 48802;
31 31
     
32
-   /**
33
-    * @var string
34
-    */
32
+    /**
33
+     * @var string
34
+     */
35 35
     protected $statement;
36 36
     
37
-   /**
38
-    * @var OperationResult
39
-    */
37
+    /**
38
+     * @var OperationResult
39
+     */
40 40
     protected $result;
41 41
     
42
-   /**
43
-    * @var Mailcode_Parser_Statement_Tokenizer
44
-    */
42
+    /**
43
+     * @var Mailcode_Parser_Statement_Tokenizer
44
+     */
45 45
     protected $tokenizer;
46 46
     
47
-   /**
48
-    * @var Mailcode_Parser_Statement_Info|NULL
49
-    */
47
+    /**
48
+     * @var Mailcode_Parser_Statement_Info|NULL
49
+     */
50 50
     protected $info;
51 51
     
52 52
     public function __construct(string $statement)
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         if($unknown)
103 103
         {
104 104
             $this->result->makeError(
105
-               t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')',
105
+                t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')',
106 106
                 self::VALIDATION_UNQUOTED_STRING_LITERALS
107 107
             );
108 108
         }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     
76 76
     public function getInfo() : Mailcode_Parser_Statement_Info
77 77
     {
78
-        if($this->info instanceof Mailcode_Parser_Statement_Info)
78
+        if ($this->info instanceof Mailcode_Parser_Statement_Info)
79 79
         {
80 80
             return $this->info; 
81 81
         }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     
88 88
     protected function validate() : void
89 89
     {
90
-        if(!$this->tokenizer->hasTokens())
90
+        if (!$this->tokenizer->hasTokens())
91 91
         {
92 92
             $this->result->makeError(
93 93
                 t('Empty statement'),
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         
100 100
         $unknown = $this->tokenizer->getFirstUnknown();
101 101
         
102
-        if($unknown)
102
+        if ($unknown)
103 103
         {
104 104
             $this->result->makeError(
105 105
                t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')',
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard.php 2 patches
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -61,50 +61,50 @@  discard block
 block discarded – undo
61 61
     
62 62
     const ERROR_NOT_A_SINGLE_LINES_FORMATTER = 47806;
63 63
     
64
-   /**
65
-    * @var Mailcode_Parser
66
-    */
64
+    /**
65
+     * @var Mailcode_Parser
66
+     */
67 67
     protected $parser;
68 68
     
69
-   /**
70
-    * @var Mailcode_Collection
71
-    */
69
+    /**
70
+     * @var Mailcode_Collection
71
+     */
72 72
     protected $commands;
73 73
     
74
-   /**
75
-    * @var string
76
-    */
74
+    /**
75
+     * @var string
76
+     */
77 77
     protected $originalString;
78 78
     
79
-   /**
80
-    * @var Mailcode_Collection
81
-    */
79
+    /**
80
+     * @var Mailcode_Collection
81
+     */
82 82
     protected $collection;
83 83
     
84
-   /**
85
-    * Counter for the placeholders, global for all placeholders.
86
-    * @var integer
87
-    */
84
+    /**
85
+     * Counter for the placeholders, global for all placeholders.
86
+     * @var integer
87
+     */
88 88
     private static $counter = 0;
89 89
     
90
-   /**
91
-    * @var Mailcode_Parser_Safeguard_Placeholder[]
92
-    */
90
+    /**
91
+     * @var Mailcode_Parser_Safeguard_Placeholder[]
92
+     */
93 93
     protected $placeholders;
94 94
     
95
-   /**
96
-    * @var string
97
-    */
95
+    /**
96
+     * @var string
97
+     */
98 98
     protected $delimiter = '__';
99 99
     
100
-   /**
101
-    * @var string[]|NULL
102
-    */
100
+    /**
101
+     * @var string[]|NULL
102
+     */
103 103
     protected $placeholderStrings;
104 104
     
105
-   /**
106
-    * @var Mailcode_Parser_Safeguard_Formatter
107
-    */
105
+    /**
106
+     * @var Mailcode_Parser_Safeguard_Formatter
107
+     */
108 108
     protected $formatter;
109 109
     
110 110
     public function __construct(Mailcode_Parser $parser, string $subject)
@@ -113,25 +113,25 @@  discard block
 block discarded – undo
113 113
         $this->originalString = $subject;
114 114
     }
115 115
     
116
-   /**
117
-    * Retrieves the string the safeguard was created for.
118
-    * 
119
-    * @return string
120
-    */
116
+    /**
117
+     * Retrieves the string the safeguard was created for.
118
+     * 
119
+     * @return string
120
+     */
121 121
     public function getOriginalString() : string
122 122
     {
123 123
         return $this->originalString;
124 124
     }
125 125
     
126
-   /**
127
-    * Sets the delimiter character sequence used to prepend
128
-    * and append to the placeholders.
129
-    * 
130
-    * The delimiter's default is "__" (two underscores).
131
-    * 
132
-    * @param string $delimiter
133
-    * @return Mailcode_Parser_Safeguard
134
-    */
126
+    /**
127
+     * Sets the delimiter character sequence used to prepend
128
+     * and append to the placeholders.
129
+     * 
130
+     * The delimiter's default is "__" (two underscores).
131
+     * 
132
+     * @param string $delimiter
133
+     * @return Mailcode_Parser_Safeguard
134
+     */
135 135
     public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard
136 136
     {
137 137
         if(empty($delimiter))
@@ -153,15 +153,15 @@  discard block
 block discarded – undo
153 153
         return $this->delimiter;
154 154
     }
155 155
     
156
-   /**
157
-    * Retrieves the safe string in which all commands have been replaced
158
-    * by placeholder strings.
159
-    *
160
-    * @return string
161
-    * @throws Mailcode_Exception 
162
-    *
163
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
164
-    */
156
+    /**
157
+     * Retrieves the safe string in which all commands have been replaced
158
+     * by placeholder strings.
159
+     *
160
+     * @return string
161
+     * @throws Mailcode_Exception 
162
+     *
163
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
164
+     */
165 165
     public function makeSafe() : string
166 166
     {
167 167
         $this->requireValidCollection();
@@ -201,10 +201,10 @@  discard block
 block discarded – undo
201 201
         );
202 202
     }
203 203
     
204
-   /**
205
-    * Enables the formatter that ensures that all commands that
206
-    * @return Mailcode_Parser_Safeguard_Formatter_SingleLines
207
-    */
204
+    /**
205
+     * Enables the formatter that ensures that all commands that
206
+     * @return Mailcode_Parser_Safeguard_Formatter_SingleLines
207
+     */
208 208
     public function selectSingleLinesFormatter() : Mailcode_Parser_Safeguard_Formatter_SingleLines
209 209
     {
210 210
         $formatter = $this->selectFormatter('SingleLines');
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
         );
225 225
     }
226 226
     
227
-   /**
228
-    * Retrieves an associative array with pairs of
229
-    * [placeholder string => replacement text]. 
230
-    * 
231
-    * @param bool $highlighted
232
-    * @return string[]string
233
-    */
227
+    /**
228
+     * Retrieves an associative array with pairs of
229
+     * [placeholder string => replacement text]. 
230
+     * 
231
+     * @param bool $highlighted
232
+     * @return string[]string
233
+     */
234 234
     protected function getReplaces(bool $highlighted=false) : array
235 235
     {
236 236
         $placeholders = $this->getPlaceholders();
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
     }
258 258
     
259 259
     
260
-   /**
261
-    * Retrieves all placeholders that have to be added to
262
-    * the subject text.
263
-    * 
264
-    * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
265
-    */
260
+    /**
261
+     * Retrieves all placeholders that have to be added to
262
+     * the subject text.
263
+     * 
264
+     * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
265
+     */
266 266
     public function getPlaceholders()
267 267
     {
268 268
         if(isset($this->placeholders))
@@ -314,46 +314,46 @@  discard block
 block discarded – undo
314 314
         return str_replace($placeholderStrings, array_values($replaces), $string);
315 315
     }
316 316
     
317
-   /**
318
-    * Makes the string whole again after transforming or filtering it,
319
-    * by replacing the command placeholders with the original commands.
320
-    *
321
-    * @param string $string
322
-    * @return string
323
-    * @throws Mailcode_Exception
324
-    *
325
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
326
-    * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING
327
-    */
317
+    /**
318
+     * Makes the string whole again after transforming or filtering it,
319
+     * by replacing the command placeholders with the original commands.
320
+     *
321
+     * @param string $string
322
+     * @return string
323
+     * @throws Mailcode_Exception
324
+     *
325
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
326
+     * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING
327
+     */
328 328
     public function makeWhole(string $string) : string
329 329
     {
330 330
         return $this->restore($string, false);
331 331
     }
332 332
 
333
-   /**
334
-    * Like makeWhole(), but replaces the commands with a syntax
335
-    * highlighted version, meant for human readable texts only.
336
-    * 
337
-    * Note: the commands lose their functionality (They cannot be 
338
-    * parsed from that string again).
339
-    *
340
-    * @param string $string
341
-    * @return string
342
-    * @throws Mailcode_Exception
343
-    *
344
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
345
-    * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING
346
-    */
333
+    /**
334
+     * Like makeWhole(), but replaces the commands with a syntax
335
+     * highlighted version, meant for human readable texts only.
336
+     * 
337
+     * Note: the commands lose their functionality (They cannot be 
338
+     * parsed from that string again).
339
+     *
340
+     * @param string $string
341
+     * @return string
342
+     * @throws Mailcode_Exception
343
+     *
344
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
345
+     * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING
346
+     */
347 347
     public function makeHighlighted(string $string) : string
348 348
     {
349 349
         return $this->restore($string, true);
350 350
     }
351 351
     
352
-   /**
353
-    * Retrieves the commands collection contained in the string.
354
-    * 
355
-    * @return Mailcode_Collection
356
-    */
352
+    /**
353
+     * Retrieves the commands collection contained in the string.
354
+     * 
355
+     * @return Mailcode_Collection
356
+     */
357 357
     public function getCollection() : Mailcode_Collection
358 358
     {
359 359
         if(isset($this->collection))
@@ -371,11 +371,11 @@  discard block
 block discarded – undo
371 371
         return $this->getCollection()->isValid();
372 372
     }
373 373
     
374
-   /**
375
-    * @throws Mailcode_Exception
376
-    * 
377
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
378
-    */
374
+    /**
375
+     * @throws Mailcode_Exception
376
+     * 
377
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
378
+     */
379 379
     protected function requireValidCollection() : void
380 380
     {
381 381
         if($this->getCollection()->isValid())
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
         );
395 395
     }
396 396
     
397
-   /**
398
-    * Retrieves a list of all placeholder IDs used in the text.
399
-    * 
400
-    * @return string[]
401
-    */
397
+    /**
398
+     * Retrieves a list of all placeholder IDs used in the text.
399
+     * 
400
+     * @return string[]
401
+     */
402 402
     public function getPlaceholderStrings() : array
403 403
     {
404 404
         if(is_array($this->placeholderStrings))
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
         return in_array($subject, $ids);
426 426
     }
427 427
     
428
-   /**
429
-    * Retrieves a placeholder instance by its ID.
430
-    * 
431
-    * @param int $id
432
-    * @throws Mailcode_Exception If the placeholder was not found.
433
-    * @return Mailcode_Parser_Safeguard_Placeholder
434
-    */
428
+    /**
429
+     * Retrieves a placeholder instance by its ID.
430
+     * 
431
+     * @param int $id
432
+     * @throws Mailcode_Exception If the placeholder was not found.
433
+     * @return Mailcode_Parser_Safeguard_Placeholder
434
+     */
435 435
     public function getPlaceholderByID(int $id) : Mailcode_Parser_Safeguard_Placeholder
436 436
     {
437 437
         $placeholders = $this->getPlaceholders();
@@ -454,13 +454,13 @@  discard block
 block discarded – undo
454 454
         );
455 455
     }
456 456
     
457
-   /**
458
-    * Retrieves a placeholder instance by its replacement text.
459
-    * 
460
-    * @param string $string
461
-    * @throws Mailcode_Exception
462
-    * @return Mailcode_Parser_Safeguard_Placeholder
463
-    */
457
+    /**
458
+     * Retrieves a placeholder instance by its replacement text.
459
+     * 
460
+     * @param string $string
461
+     * @throws Mailcode_Exception
462
+     * @return Mailcode_Parser_Safeguard_Placeholder
463
+     */
464 464
     public function getPlaceholderByString(string $string) : Mailcode_Parser_Safeguard_Placeholder
465 465
     {
466 466
         $placeholders = $this->getPlaceholders();
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     */
135 135
     public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard
136 136
     {
137
-        if(empty($delimiter))
137
+        if (empty($delimiter))
138 138
         {
139 139
             throw new Mailcode_Exception(
140 140
                 'Empty delimiter',
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         $safe = str_replace(array_values($replaces), array_keys($replaces), $this->originalString);
172 172
 
173 173
         // If a formatter has been selected, let it modify the string.
174
-        if(isset($this->formatter))
174
+        if (isset($this->formatter))
175 175
         {
176 176
             $safe = $this->formatter->format($safe);
177 177
         }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     {
184 184
         $class = 'Mailcode\Mailcode_Parser_Safeguard_Formatter_'.$formatterID;
185 185
         
186
-        if(class_exists($class))
186
+        if (class_exists($class))
187 187
         {
188 188
             $this->formatter = new $class($this);
189 189
             
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     {
210 210
         $formatter = $this->selectFormatter('SingleLines');
211 211
         
212
-        if($formatter instanceof Mailcode_Parser_Safeguard_Formatter_SingleLines)
212
+        if ($formatter instanceof Mailcode_Parser_Safeguard_Formatter_SingleLines)
213 213
         {
214 214
             return $formatter;
215 215
         }
@@ -231,17 +231,17 @@  discard block
 block discarded – undo
231 231
     * @param bool $highlighted
232 232
     * @return string[]string
233 233
     */
234
-    protected function getReplaces(bool $highlighted=false) : array
234
+    protected function getReplaces(bool $highlighted = false) : array
235 235
     {
236 236
         $placeholders = $this->getPlaceholders();
237 237
         
238 238
         $replaces = array();
239 239
         
240
-        foreach($placeholders as $placeholder)
240
+        foreach ($placeholders as $placeholder)
241 241
         {
242 242
             $replace = '';
243 243
             
244
-            if($highlighted)
244
+            if ($highlighted)
245 245
             {
246 246
                 $replace = $placeholder->getHighlightedText();
247 247
             }
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
     */
266 266
     public function getPlaceholders()
267 267
     {
268
-        if(isset($this->placeholders))
268
+        if (isset($this->placeholders))
269 269
         {
270 270
             return $this->placeholders;
271 271
         }
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
         
275 275
         $cmds = $this->getCollection()->getGroupedByHash();
276 276
         
277
-        foreach($cmds as $command)
277
+        foreach ($cmds as $command)
278 278
         {
279 279
             self::$counter++;
280 280
             
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
         return $this->placeholders;
289 289
     }
290 290
     
291
-    protected function restore(string $string, bool $highlighted=false) : string
291
+    protected function restore(string $string, bool $highlighted = false) : string
292 292
     {
293 293
         $this->requireValidCollection();
294 294
         
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
         
297 297
         $placeholderStrings = array_keys($replaces);
298 298
         
299
-        foreach($placeholderStrings as $search)
299
+        foreach ($placeholderStrings as $search)
300 300
         {
301
-            if(!strstr($string, $search))
301
+            if (!strstr($string, $search))
302 302
             {
303 303
                 throw new Mailcode_Exception(
304 304
                     'Command placeholder not found',
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
     */
357 357
     public function getCollection() : Mailcode_Collection
358 358
     {
359
-        if(isset($this->collection))
359
+        if (isset($this->collection))
360 360
         {
361 361
             return $this->collection;
362 362
         }
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
     */
379 379
     protected function requireValidCollection() : void
380 380
     {
381
-        if($this->getCollection()->isValid())
381
+        if ($this->getCollection()->isValid())
382 382
         {
383 383
             return;
384 384
         }
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
     */
402 402
     public function getPlaceholderStrings() : array
403 403
     {
404
-        if(is_array($this->placeholderStrings))
404
+        if (is_array($this->placeholderStrings))
405 405
         {
406 406
             return $this->placeholderStrings;
407 407
         }
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
         
411 411
         $this->placeholderStrings = array();
412 412
         
413
-        foreach($placeholders as $placeholder)
413
+        foreach ($placeholders as $placeholder)
414 414
         {
415 415
             $this->placeholderStrings[] = $placeholder->getReplacementText();
416 416
         }
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
     {
437 437
         $placeholders = $this->getPlaceholders();
438 438
         
439
-        foreach($placeholders as $placeholder)
439
+        foreach ($placeholders as $placeholder)
440 440
         {
441
-            if($placeholder->getID() === $id)
441
+            if ($placeholder->getID() === $id)
442 442
             {
443 443
                 return $placeholder;
444 444
             }
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
     {
466 466
         $placeholders = $this->getPlaceholders();
467 467
         
468
-        foreach($placeholders as $placeholder)
468
+        foreach ($placeholders as $placeholder)
469 469
         {
470
-            if($placeholder->getReplacementText() === $string)
470
+            if ($placeholder->getReplacementText() === $string)
471 471
             {
472 472
                 return $placeholder;
473 473
             }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowVariable.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     {
70 70
         $this->validate();
71 71
         
72
-        if($this->variable instanceof Mailcode_Variables_Variable)
72
+        if ($this->variable instanceof Mailcode_Variables_Variable)
73 73
         {
74 74
             return $this->variable;
75 75
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
          $vars = $this->getVariables()->getGroupedByName();
101 101
          $amount = count($vars);
102 102
          
103
-         if($amount === 1)
103
+         if ($amount === 1)
104 104
          {
105 105
              $this->variable = array_pop($vars);
106 106
              return;
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowSnippet.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     {
66 66
         $this->validate();
67 67
         
68
-        if($this->variable instanceof Mailcode_Variables_Variable)
68
+        if ($this->variable instanceof Mailcode_Variables_Variable)
69 69
         {
70 70
             return $this->variable;
71 71
         }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         
96 96
         $var = $info->getVariableByIndex(0);
97 97
         
98
-        if($var)
98
+        if ($var)
99 99
         {
100 100
             $this->variable = $var->getVariable();
101 101
             return;
Please login to merge, or discard this patch.
src/Mailcode/Commands.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
     
28 28
     const ERROR_INVALID_DUMMY_COMMAND_TYPE = 45903;
29 29
     
30
-   /**
31
-    * @var Mailcode_Commands_Command[]
32
-    */
30
+    /**
31
+     * @var Mailcode_Commands_Command[]
32
+     */
33 33
     private $commands = array();
34 34
     
35
-   /**
36
-    * @var string[]Mailcode_Commands_Command
37
-    */
35
+    /**
36
+     * @var string[]Mailcode_Commands_Command
37
+     */
38 38
     private static $dummyCommands = array();
39 39
     
40
-   /**
41
-    * Retrieves a list of all available command IDs.
42
-    * 
43
-    * @return string[]
44
-    */
40
+    /**
41
+     * Retrieves a list of all available command IDs.
42
+     * 
43
+     * @return string[]
44
+     */
45 45
     public function getIDs() : array
46 46
     {
47 47
         static $ids = array();
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
         return $ids;
55 55
     }
56 56
     
57
-   /**
58
-    * Retrieves a list of all available commands, sorted by label.
59
-    * 
60
-    * NOTE: These instances are only used for information purposes.
61
-    * 
62
-    * @return Mailcode_Commands_Command[]
63
-    */
57
+    /**
58
+     * Retrieves a list of all available commands, sorted by label.
59
+     * 
60
+     * NOTE: These instances are only used for information purposes.
61
+     * 
62
+     * @return Mailcode_Commands_Command[]
63
+     */
64 64
     public function getAll()
65 65
     {
66 66
         if(!empty($this->commands)) {
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
         return $result;
87 87
     }
88 88
     
89
-   /**
90
-    * Gets an available command by its ID.
91
-    * 
92
-    * @param string $id
93
-    * @return Mailcode_Commands_Command
94
-    */
89
+    /**
90
+     * Gets an available command by its ID.
91
+     * 
92
+     * @param string $id
93
+     * @return Mailcode_Commands_Command
94
+     */
95 95
     public function getByID(string $id) : Mailcode_Commands_Command
96 96
     {
97 97
         static $instances = array();
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
         return $instances[$id];
105 105
     }
106 106
     
107
-   /**
108
-    * Retrieves the ID of a command by its name.
109
-    * 
110
-    * @param string $name
111
-    * @throws Mailcode_Exception
112
-    * @return string
113
-    * 
114
-    * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST
115
-    */
107
+    /**
108
+     * Retrieves the ID of a command by its name.
109
+     * 
110
+     * @param string $name
111
+     * @throws Mailcode_Exception
112
+     * @return string
113
+     * 
114
+     * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST
115
+     */
116 116
     public function getIDByName(string $name) : string
117 117
     {
118 118
         $items = $this->getAll();
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
         return in_array($id, $ids);
142 142
     }
143 143
     
144
-   /**
145
-    * Checks wether the specified name exists.
146
-    * 
147
-    * @param string $name For example: "showvar".
148
-    * @return bool
149
-    */
144
+    /**
145
+     * Checks wether the specified name exists.
146
+     * 
147
+     * @param string $name For example: "showvar".
148
+     * @return bool
149
+     */
150 150
     public function nameExists(string $name) : bool
151 151
     {
152 152
         $items = $this->getAll();
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
         return $class;
201 201
     }
202 202
     
203
-   /**
204
-    * Retrieves the dummy command of the specified type, which
205
-    * is used to retrieve information on the command's capabilities.
206
-    *  
207
-    * @param string $id
208
-    * @return Mailcode_Commands_Command
209
-    */
203
+    /**
204
+     * Retrieves the dummy command of the specified type, which
205
+     * is used to retrieve information on the command's capabilities.
206
+     *  
207
+     * @param string $id
208
+     * @return Mailcode_Commands_Command
209
+     */
210 210
     private function getDummyCommand(string $id) : Mailcode_Commands_Command
211 211
     {
212 212
         if(!isset(self::$dummyCommands[$id]))
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     {
47 47
         static $ids = array();
48 48
         
49
-        if(empty($ids)) {
49
+        if (empty($ids)) {
50 50
             $ids = \AppUtils\FileHelper::createFileFinder(__DIR__.'/Commands/Command')
51 51
             ->getPHPClassNames();
52 52
         }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     */
64 64
     public function getAll()
65 65
     {
66
-        if(!empty($this->commands)) {
66
+        if (!empty($this->commands)) {
67 67
             return $this->commands;
68 68
         }
69 69
         
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         
72 72
         $result = array();
73 73
         
74
-        foreach($ids as $id) 
74
+        foreach ($ids as $id) 
75 75
         {
76 76
             $result[] = $this->getDummyCommand($id);
77 77
         }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     {
97 97
         static $instances = array();
98 98
         
99
-        if(!isset($instances[$id])) 
99
+        if (!isset($instances[$id])) 
100 100
         {
101 101
             $instances[$id] = $this->createCommand($id, '__dummy', '', '');
102 102
         }
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $items = $this->getAll();
119 119
         
120
-        foreach($items as $item) 
120
+        foreach ($items as $item) 
121 121
         {
122
-            if($item->getName() === $name) {
122
+            if ($item->getName() === $name) {
123 123
                 return $item->getID();
124 124
             }
125 125
         }
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
     {
152 152
         $items = $this->getAll();
153 153
         
154
-        foreach($items as $item)
154
+        foreach ($items as $item)
155 155
         {
156
-            if($item->getName() === $name) {
156
+            if ($item->getName() === $name) {
157 157
                 return true;
158 158
             }
159 159
         }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     {
166 166
         $class = $this->resolveClassName($id, $type);
167 167
         
168
-        if(!class_exists($class))
168
+        if (!class_exists($class))
169 169
         {
170 170
             throw new Mailcode_Exception(
171 171
                 'No such command',
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
         
188 188
         $dummy = $this->getDummyCommand($id);
189 189
         
190
-        if($dummy->supportsType())
190
+        if ($dummy->supportsType())
191 191
         {
192
-            if(empty($type))
192
+            if (empty($type))
193 193
             {
194 194
                 $type = $dummy->getDefaultType();
195 195
             }
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
     */
210 210
     private function getDummyCommand(string $id) : Mailcode_Commands_Command
211 211
     {
212
-        if(!isset(self::$dummyCommands[$id]))
212
+        if (!isset(self::$dummyCommands[$id]))
213 213
         {
214 214
             $class = 'Mailcode\Mailcode_Commands_Command_'.$id;
215 215
             self::$dummyCommands[$id] = new $class('__dummy');
216 216
         }
217 217
         
218
-        if(self::$dummyCommands[$id] instanceof Mailcode_Commands_Command)
218
+        if (self::$dummyCommands[$id] instanceof Mailcode_Commands_Command)
219 219
         {
220 220
             return self::$dummyCommands[$id];
221 221
         }
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/IfVariable.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -23,19 +23,19 @@  discard block
 block discarded – undo
23 23
  */
24 24
 trait Mailcode_Traits_Commands_IfVariable
25 25
 {
26
-   /**
27
-    * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL
28
-    */
26
+    /**
27
+     * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL
28
+     */
29 29
     protected $variableToken;
30 30
     
31
-   /**
32
-    * @var Mailcode_Parser_Statement_Tokenizer_Token_Operand|NULL
33
-    */
31
+    /**
32
+     * @var Mailcode_Parser_Statement_Tokenizer_Token_Operand|NULL
33
+     */
34 34
     protected $comparisonToken;
35 35
     
36
-   /**
37
-    * @var Mailcode_Parser_Statement_Tokenizer_Type_Value|NULL
38
-    */
36
+    /**
37
+     * @var Mailcode_Parser_Statement_Tokenizer_Type_Value|NULL
38
+     */
39 39
     protected $valueToken;
40 40
     
41 41
     protected function getValidations() : array
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
         );
124 124
     }
125 125
     
126
-   /**
127
-    * Retrieves the variable being compared.
128
-    *
129
-    * @return Mailcode_Variables_Variable
130
-    */
126
+    /**
127
+     * Retrieves the variable being compared.
128
+     *
129
+     * @return Mailcode_Variables_Variable
130
+     */
131 131
     public function getVariable() : Mailcode_Variables_Variable
132 132
     {
133 133
         if($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
         );
143 143
     }
144 144
     
145
-   /**
146
-    * Retrieves the comparison operator sign.
147
-    * 
148
-    * @throws Mailcode_Exception
149
-    * @return string The comparison string, e.g. "==", "!=", etc.
150
-    */
145
+    /**
146
+     * Retrieves the comparison operator sign.
147
+     * 
148
+     * @throws Mailcode_Exception
149
+     * @return string The comparison string, e.g. "==", "!=", etc.
150
+     */
151 151
     public function getComparator() : string
152 152
     {
153 153
         if($this->comparisonToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
         );
163 163
     }
164 164
     
165
-   /**
166
-    * Retrieves the unquoted value 
167
-    * @return string
168
-    */
165
+    /**
166
+     * Retrieves the unquoted value 
167
+     * @return string
168
+     */
169 169
     public function getValue() : string
170 170
     {
171 171
         if($this->valueToken instanceof Mailcode_Parser_Statement_Tokenizer_Type_Value)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         
54 54
         $var = $info->getVariableByIndex(0);
55 55
         
56
-        if($var !== null)
56
+        if ($var !== null)
57 57
         {
58 58
             $this->variableToken = $var;
59 59
             return;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         
72 72
         $operand = $info->getOperandByIndex(1);
73 73
         
74
-        if($operand === null)
74
+        if ($operand === null)
75 75
         {
76 76
             $this->validationResult->makeError(
77 77
                 t('No operand sign after the variable name.'),
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             return;
82 82
         }
83 83
         
84
-        if(!$operand->isComparator())
84
+        if (!$operand->isComparator())
85 85
         {
86 86
             $this->validationResult->makeError(
87 87
                 t('The operand sign is not a comparison operand.'),
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         
101 101
         $token = $info->getTokenByIndex(2);
102 102
         
103
-        if($token === null)
103
+        if ($token === null)
104 104
         {
105 105
             $this->validationResult->makeError(
106 106
                 t('Nothing found after the comparison operand.'),
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             return;
111 111
         }
112 112
         
113
-        if($token instanceof Mailcode_Parser_Statement_Tokenizer_Type_Value)
113
+        if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Type_Value)
114 114
         {
115 115
             $this->valueToken = $token;
116 116
             
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     */
131 131
     public function getVariable() : Mailcode_Variables_Variable
132 132
     {
133
-        if($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
133
+        if ($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
134 134
         {
135 135
             return $this->variableToken->getVariable();
136 136
         }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     */
151 151
     public function getComparator() : string
152 152
     {
153
-        if($this->comparisonToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
153
+        if ($this->comparisonToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
154 154
         {
155 155
             return $this->comparisonToken->getOperand();
156 156
         }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     */
169 169
     public function getValue() : string
170 170
     {
171
-        if($this->valueToken instanceof Mailcode_Parser_Statement_Tokenizer_Type_Value)
171
+        if ($this->valueToken instanceof Mailcode_Parser_Statement_Tokenizer_Type_Value)
172 172
         {
173 173
             return $this->valueToken->getValue();
174 174
         }
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/IfContains.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
      */
29 29
     protected $variableToken;
30 30
 
31
-   /**
32
-    * @var Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral|NULL
33
-    */
31
+    /**
32
+     * @var Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral|NULL
33
+     */
34 34
     protected $stringToken;
35 35
     
36
-   /**
37
-    * @var boolean
38
-    */
36
+    /**
37
+     * @var boolean
38
+     */
39 39
     protected $caseInsensitive = false;
40 40
     
41 41
     protected function getValidations() : array
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
         );
132 132
     }
133 133
 
134
-   /**
135
-    * Retrieves the variable being compared.
136
-    *
137
-    * @return Mailcode_Variables_Variable
138
-    */
134
+    /**
135
+     * Retrieves the variable being compared.
136
+     *
137
+     * @return Mailcode_Variables_Variable
138
+     */
139 139
     public function getVariable() : Mailcode_Variables_Variable
140 140
     {
141 141
         if($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         
53 53
         $variable = $info->getVariableByIndex(0);
54 54
         
55
-        if($variable !== null)
55
+        if ($variable !== null)
56 56
         {
57 57
             $this->variableToken = $variable;
58 58
             return;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         // first variant: variable "Search term"
72 72
         $string = $info->getStringLiteralByIndex(1);
73 73
         
74
-        if($string !== null)
74
+        if ($string !== null)
75 75
         {
76 76
             $this->stringToken = $string;
77 77
             return;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         // second variant: variable insensitive: "Search term"
88 88
         $keyword = $info->getKeywordByIndex(1);
89 89
         
90
-        if($keyword === null)
90
+        if ($keyword === null)
91 91
         {
92 92
             $this->validationResult->makeError(
93 93
                 t('Expected a search term or the %1$s keyword after the variable name.', 'insensitive:'),
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             return;
98 98
         }
99 99
         
100
-        if($keyword->getKeyword() !== 'insensitive:')
100
+        if ($keyword->getKeyword() !== 'insensitive:')
101 101
         {
102 102
             $this->validationResult->makeError(
103 103
                 t('Invalid keyword %1$s.', $keyword->getKeyword()).' '.
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         
120 120
         $string = $info->getStringLiteralByIndex(2);
121 121
         
122
-        if($string !== null)
122
+        if ($string !== null)
123 123
         {
124 124
             $this->stringToken = $string;
125 125
             return;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     */
139 139
     public function getVariable() : Mailcode_Variables_Variable
140 140
     {
141
-        if($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
141
+        if ($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
142 142
         {
143 143
             return $this->variableToken->getVariable();
144 144
         }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     
158 158
     public function getSearchTerm() : string
159 159
     {
160
-        if($this->stringToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral)
160
+        if ($this->stringToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral)
161 161
         {
162 162
             return $this->stringToken->getNormalized();
163 163
         }
Please login to merge, or discard this patch.
src/Mailcode/Collection.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         
100 100
         $errors = $this->errors;
101 101
         
102
-        if(!$result->isValid())
102
+        if (!$result->isValid())
103 103
         {
104 104
             $errors[] = new Mailcode_Collection_Error_Message(
105 105
                 '',
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     {
116 116
         $errors = $this->getErrors();
117 117
         
118
-        if(!empty($errors))
118
+        if (!empty($errors))
119 119
         {
120 120
             return array_shift($errors);
121 121
         }
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
     {
158 158
         $hashes = array();
159 159
         
160
-        foreach($this->commands as $command)
160
+        foreach ($this->commands as $command)
161 161
         {
162 162
             $hash = $command->getHash();
163 163
             
164
-            if(!isset($hashes[$hash]))
164
+            if (!isset($hashes[$hash]))
165 165
             {
166 166
                 $hashes[$hash] = $command;
167 167
             }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
     */
179 179
     public function addCommands(array $commands) : Mailcode_Collection
180 180
     {
181
-        foreach($commands as $command)
181
+        foreach ($commands as $command)
182 182
         {
183 183
             $this->addCommand($command);
184 184
         }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     {
198 198
         $collection = new Mailcode_Variables_Collection_Regular();
199 199
         
200
-        foreach($this->commands as $command)
200
+        foreach ($this->commands as $command)
201 201
         {
202 202
             $collection->mergeWith($command->getVariables());
203 203
         }
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     
208 208
     public function getValidationResult() : OperationResult
209 209
     {
210
-        if($this->validationResult instanceof OperationResult)
210
+        if ($this->validationResult instanceof OperationResult)
211 211
         {
212 212
             return $this->validationResult;
213 213
         }
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
     {
224 224
         $errors = $this->getErrors();
225 225
         
226
-        foreach($errors as $error)
226
+        foreach ($errors as $error)
227 227
         {
228
-            if($error->getCode() === $code)
228
+            if ($error->getCode() === $code)
229 229
             {
230 230
                 return true;
231 231
             }
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
     {
244 244
         $result = array();
245 245
         
246
-        foreach($this->commands as $command)
246
+        foreach ($this->commands as $command)
247 247
         {
248
-            if($command instanceof Mailcode_Commands_Command_ShowVariable)
248
+            if ($command instanceof Mailcode_Commands_Command_ShowVariable)
249 249
             {
250 250
                 $result[] = $command;
251 251
             }
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     {
259 259
         $commands = $this->getCommands();
260 260
         
261
-        if(!empty($commands))
261
+        if (!empty($commands))
262 262
         {
263 263
             return array_shift($commands);
264 264
         }
Please login to merge, or discard this patch.