Passed
Push — master ( c28222...9253d7 )
by Sebastian
02:41
created
src/Mailcode/Commands/Command.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -37,44 +37,44 @@  discard block
 block discarded – undo
37 37
 
38 38
     const META_URL_ENCODING = 'url_encoding';
39 39
 
40
-   /**
41
-    * @var string
42
-    */
40
+    /**
41
+     * @var string
42
+     */
43 43
     protected $type = '';
44 44
 
45
-   /**
46
-    * @var string
47
-    */
45
+    /**
46
+     * @var string
47
+     */
48 48
     protected $paramsString = '';
49 49
     
50
-   /**
51
-    * @var string
52
-    */
50
+    /**
51
+     * @var string
52
+     */
53 53
     protected $matchedText = '';
54 54
 
55
-   /**
56
-    * @var string
57
-    */
55
+    /**
56
+     * @var string
57
+     */
58 58
     protected $hash = '';
59 59
     
60
-   /**
61
-    * @var OperationResult
62
-    */
60
+    /**
61
+     * @var OperationResult
62
+     */
63 63
     protected $validationResult = null;
64 64
     
65
-   /**
66
-    * @var \Mailcode\Mailcode
67
-    */
65
+    /**
66
+     * @var \Mailcode\Mailcode
67
+     */
68 68
     protected $mailcode;
69 69
     
70
-   /**
71
-    * @var \Mailcode\Mailcode_Parser_Statement
72
-    */
70
+    /**
71
+     * @var \Mailcode\Mailcode_Parser_Statement
72
+     */
73 73
     protected $params;
74 74
 
75
-   /**
76
-    * @var string[] 
77
-    */
75
+    /**
76
+     * @var string[] 
77
+     */
78 78
     protected $validations = array(
79 79
         'params_empty',
80 80
         'params_keywords',
@@ -83,24 +83,24 @@  discard block
 block discarded – undo
83 83
         'type_unsupported'
84 84
     );
85 85
     
86
-   /**
87
-    * @var string
88
-    */
86
+    /**
87
+     * @var string
88
+     */
89 89
     protected $comment = '';
90 90
     
91
-   /**
92
-    * @var Mailcode_Commands_LogicKeywords|NULL
93
-    */
91
+    /**
92
+     * @var Mailcode_Commands_LogicKeywords|NULL
93
+     */
94 94
     protected $logicKeywords;
95 95
     
96
-   /**
97
-    * @var Mailcode_Parser_Statement_Validator
98
-    */
96
+    /**
97
+     * @var Mailcode_Parser_Statement_Validator
98
+     */
99 99
     protected $validator;
100 100
     
101
-   /**
102
-    * @var boolean
103
-    */
101
+    /**
102
+     * @var boolean
103
+     */
104 104
     private $validated = false;
105 105
 
106 106
     /**
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
         
131 131
     }
132 132
 
133
-   /**
134
-    * Sets the command's parent opening command, if any.
135
-    * NOTE: This is set automatically by the parser, and
136
-    * should not be called manually.
137
-    *
138
-    * @param Mailcode_Commands_Command $command
139
-    */
133
+    /**
134
+     * Sets the command's parent opening command, if any.
135
+     * NOTE: This is set automatically by the parser, and
136
+     * should not be called manually.
137
+     *
138
+     * @param Mailcode_Commands_Command $command
139
+     */
140 140
     public function setParent(Mailcode_Commands_Command $command) : void
141 141
     {
142 142
         $this->parent = $command;
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
         return $this->parent;
153 153
     }
154 154
     
155
-   /**
156
-    * @return string The ID of the command = the name of the command class file.
157
-    */
155
+    /**
156
+     * @return string The ID of the command = the name of the command class file.
157
+     */
158 158
     public function getID() : string
159 159
     {
160 160
         // account for commands with types: If_Variable should still return If.
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
         return array_shift($tokens);
164 164
     }
165 165
     
166
-   /**
167
-    * Sets an optional comment that is not used anywhere, but
168
-    * can be used by the application to track why a command is
169
-    * used somewhere. 
170
-    * 
171
-    * @param string $comment
172
-    * @return Mailcode_Commands_Command
173
-    */
166
+    /**
167
+     * Sets an optional comment that is not used anywhere, but
168
+     * can be used by the application to track why a command is
169
+     * used somewhere. 
170
+     * 
171
+     * @param string $comment
172
+     * @return Mailcode_Commands_Command
173
+     */
174 174
     public function setComment(string $comment) : Mailcode_Commands_Command
175 175
     {
176 176
         $this->comment = $comment;
@@ -178,34 +178,34 @@  discard block
 block discarded – undo
178 178
         return $this;
179 179
     }
180 180
     
181
-   /**
182
-    * Retrieves the previously set comment, if any.
183
-    * 
184
-    * @return string
185
-    */
181
+    /**
182
+     * Retrieves the previously set comment, if any.
183
+     * 
184
+     * @return string
185
+     */
186 186
     public function getComment() : string
187 187
     {
188 188
         return $this->comment;
189 189
     }
190 190
     
191
-   /**
192
-    * Checks whether this is a dummy command, which is only
193
-    * used to access information on the command type. It cannot
194
-    * be used as an actual live command.
195
-    * 
196
-    * @return bool
197
-    */
191
+    /**
192
+     * Checks whether this is a dummy command, which is only
193
+     * used to access information on the command type. It cannot
194
+     * be used as an actual live command.
195
+     * 
196
+     * @return bool
197
+     */
198 198
     public function isDummy() : bool
199 199
     {
200 200
         return $this->type === '__dummy';
201 201
     }
202 202
     
203
-   /**
204
-    * Retrieves a hash of the actual matched command string,
205
-    * which is used in collections to detect duplicate commands.
206
-    * 
207
-    * @return string
208
-    */
203
+    /**
204
+     * Retrieves a hash of the actual matched command string,
205
+     * which is used in collections to detect duplicate commands.
206
+     * 
207
+     * @return string
208
+     */
209 209
     public function getHash() : string
210 210
     {
211 211
         $this->requireNonDummy();
@@ -307,9 +307,9 @@  discard block
 block discarded – undo
307 307
         return $this->validationResult->isValid();
308 308
     }
309 309
     
310
-   /**
311
-    * @return string[]
312
-    */
310
+    /**
311
+     * @return string[]
312
+     */
313 313
     abstract protected function getValidations() : array;
314 314
     
315 315
     protected function validateSyntax_params_empty() : void
@@ -478,12 +478,12 @@  discard block
 block discarded – undo
478 478
 
479 479
     abstract public function supportsURLEncoding() : bool;
480 480
     
481
-   /**
482
-    * Whether the command allows using logic keywords like "and:" or "or:"
483
-    * in the command parameters.
484
-    * 
485
-    * @return bool
486
-    */
481
+    /**
482
+     * Whether the command allows using logic keywords like "and:" or "or:"
483
+     * in the command parameters.
484
+     * 
485
+     * @return bool
486
+     */
487 487
     abstract public function supportsLogicKeywords() : bool;
488 488
     
489 489
     abstract public function generatesContent() : bool;
@@ -529,22 +529,22 @@  discard block
 block discarded – undo
529 529
         return $normalizer->normalize();
530 530
     }
531 531
     
532
-   /**
533
-    * Retrieves the names of all the command's supported types: the part
534
-    * between the command name and the colon. Example: {command type: params}.
535
-    * 
536
-    * @return string[]
537
-    */
532
+    /**
533
+     * Retrieves the names of all the command's supported types: the part
534
+     * between the command name and the colon. Example: {command type: params}.
535
+     * 
536
+     * @return string[]
537
+     */
538 538
     public function getSupportedTypes() : array
539 539
     {
540 540
         return array();
541 541
     }
542 542
     
543
-   /**
544
-    * Retrieves all variable names used in the command.
545
-    * 
546
-    * @return Mailcode_Variables_Collection_Regular
547
-    */
543
+    /**
544
+     * Retrieves all variable names used in the command.
545
+     * 
546
+     * @return Mailcode_Variables_Collection_Regular
547
+     */
548 548
     public function getVariables() : Mailcode_Variables_Collection_Regular
549 549
     {
550 550
         return Mailcode::create()->findVariables($this->paramsString);
@@ -569,26 +569,26 @@  discard block
 block discarded – undo
569 569
         );
570 570
     }
571 571
 
572
-   /**
573
-    * Sets a parameter for the translation backend. The backend can use
574
-    * these to allow command-specific configurations.
575
-    *
576
-    * @param string $name
577
-    * @param mixed $value
578
-    * @return $this
579
-    */
572
+    /**
573
+     * Sets a parameter for the translation backend. The backend can use
574
+     * these to allow command-specific configurations.
575
+     *
576
+     * @param string $name
577
+     * @param mixed $value
578
+     * @return $this
579
+     */
580 580
     public function setTranslationParam(string $name, $value)
581 581
     {
582 582
         $this->translationParams[$name] = $value;
583 583
         return $this;
584 584
     }
585 585
 
586
-   /**
587
-    * Retrieves a previously set translation parameter.
588
-    *
589
-    * @param string $name
590
-    * @return mixed
591
-    */
586
+    /**
587
+     * Retrieves a previously set translation parameter.
588
+     *
589
+     * @param string $name
590
+     * @return mixed
591
+     */
592 592
     public function getTranslationParam(string $name)
593 593
     {
594 594
         if(isset($this->translationParams[$name]))
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     protected $parent = null;
116 116
 
117
-    public function __construct(string $type='', string $paramsString='', string $matchedText='')
117
+    public function __construct(string $type = '', string $paramsString = '', string $matchedText = '')
118 118
     {
119 119
         $this->type = $type;
120 120
         $this->paramsString = html_entity_decode($paramsString);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     {
211 211
         $this->requireNonDummy();
212 212
         
213
-        if($this->hash === '') {
213
+        if ($this->hash === '') {
214 214
             $this->hash = md5($this->matchedText);
215 215
         }
216 216
         
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
     
220 220
     protected function requireNonDummy() : void
221 221
     {
222
-        if(!$this->isDummy())
222
+        if (!$this->isDummy())
223 223
         {
224 224
             return;
225 225
         }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     
239 239
     protected function validate() : OperationResult
240 240
     {
241
-        if(!$this->validated)
241
+        if (!$this->validated)
242 242
         {
243 243
             $this->requireNonDummy();
244 244
             $this->validateSyntax();
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
     
252 252
     public function getValidationResult() :  OperationResult
253 253
     {
254
-        if(isset($this->validationResult)) 
254
+        if (isset($this->validationResult)) 
255 255
         {
256 256
             return $this->validationResult;
257 257
         }
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
     {
268 268
         $validations = $this->resolveValidations();
269 269
 
270
-        foreach($validations as $validation)
270
+        foreach ($validations as $validation)
271 271
         {
272 272
             // break off at the first validation issue
273
-            if(!$this->validateSyntaxMethod($validation))
273
+            if (!$this->validateSyntaxMethod($validation))
274 274
             {
275 275
                 return;
276 276
             }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     {
290 290
         $method = 'validateSyntax_'.$validation;
291 291
         
292
-        if(!method_exists($this, $method))
292
+        if (!method_exists($this, $method))
293 293
         {
294 294
             throw new Mailcode_Exception(
295 295
                 'Missing validation method ['.$validation.']',
@@ -314,12 +314,12 @@  discard block
 block discarded – undo
314 314
     
315 315
     protected function validateSyntax_params_empty() : void
316 316
     {
317
-        if(!$this->requiresParameters())
317
+        if (!$this->requiresParameters())
318 318
         {
319 319
             return;
320 320
         }
321 321
         
322
-        if(empty($this->paramsString))
322
+        if (empty($this->paramsString))
323 323
         {
324 324
             $this->validationResult->makeError(
325 325
                 t('Parameters have to be specified.'),
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
     
332 332
     protected function validateSyntax_params_keywords() : void
333 333
     {
334
-        if(!$this->supportsLogicKeywords())
334
+        if (!$this->supportsLogicKeywords())
335 335
         {
336 336
             return;
337 337
         }
338 338
         
339 339
         $this->logicKeywords = new Mailcode_Commands_LogicKeywords($this, $this->paramsString);
340 340
         
341
-        if(!$this->logicKeywords->isValid())
341
+        if (!$this->logicKeywords->isValid())
342 342
         {
343 343
             $this->validationResult->makeError(
344 344
                 t('Invalid parameters:').' '.$this->logicKeywords->getErrorMessage(),
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
     
354 354
     protected function validateSyntax_params_parse() : void
355 355
     {
356
-        if(!$this->requiresParameters())
356
+        if (!$this->requiresParameters())
357 357
         {
358 358
             return;
359 359
         }
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
             $this->hasFreeformParameters()
364 364
         );
365 365
 
366
-        if(!$this->params->isValid())
366
+        if (!$this->params->isValid())
367 367
         {
368 368
             $error = $this->params->getValidationResult();
369 369
             
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
 
386 386
     protected function validateSyntax_type_supported() : void
387 387
     {
388
-        if(!$this->supportsType() || empty($this->type))
388
+        if (!$this->supportsType() || empty($this->type))
389 389
         {
390 390
             return;
391 391
         }
392 392
         
393 393
         $types = $this->getSupportedTypes();
394 394
 
395
-        if(!in_array($this->type, $types))
395
+        if (!in_array($this->type, $types))
396 396
         {
397 397
             $this->validationResult->makeError(
398 398
                 t('The command addon %1$s is not supported.', $this->type).' '.
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
     
407 407
     protected function validateSyntax_type_unsupported() : void
408 408
     {
409
-        if($this->supportsType() || empty($this->type))
409
+        if ($this->supportsType() || empty($this->type))
410 410
         {
411 411
             return;
412 412
         }
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
     
425 425
     public function getType() : string
426 426
     {
427
-        if($this->supportsType())
427
+        if ($this->supportsType())
428 428
         {
429 429
             return $this->type;
430 430
         }
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
     
445 445
     public function getHighlighted() : string
446 446
     {
447
-        if(!$this->isValid())
447
+        if (!$this->isValid())
448 448
         {
449 449
             return '';
450 450
         }
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
     
456 456
     public function getParamsString() : string
457 457
     {
458
-        if($this->requiresParameters())
458
+        if ($this->requiresParameters())
459 459
         {
460 460
             return $this->paramsString;
461 461
         }
@@ -492,22 +492,22 @@  discard block
 block discarded – undo
492 492
     
493 493
     public final function getCommandType() : string
494 494
     {
495
-        if($this instanceof Mailcode_Commands_Command_Type_Closing)
495
+        if ($this instanceof Mailcode_Commands_Command_Type_Closing)
496 496
         {
497 497
             return 'Closing';
498 498
         }
499 499
         
500
-        if($this instanceof Mailcode_Commands_Command_Type_Opening)
500
+        if ($this instanceof Mailcode_Commands_Command_Type_Opening)
501 501
         {
502 502
             return 'Opening';
503 503
         }
504 504
         
505
-        if($this instanceof Mailcode_Commands_Command_Type_Sibling)
505
+        if ($this instanceof Mailcode_Commands_Command_Type_Sibling)
506 506
         {
507 507
             return 'Sibling';
508 508
         }
509 509
         
510
-        if($this instanceof Mailcode_Commands_Command_Type_Standalone)
510
+        if ($this instanceof Mailcode_Commands_Command_Type_Standalone)
511 511
         {
512 512
             return 'Standalone';
513 513
         }
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
     
558 558
     public function getLogicKeywords() : Mailcode_Commands_LogicKeywords
559 559
     {
560
-        if($this->supportsLogicKeywords() && isset($this->logicKeywords))
560
+        if ($this->supportsLogicKeywords() && isset($this->logicKeywords))
561 561
         {
562 562
             return $this->logicKeywords;
563 563
         }
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
     */
592 592
     public function getTranslationParam(string $name)
593 593
     {
594
-        if(isset($this->translationParams[$name]))
594
+        if (isset($this->translationParams[$name]))
595 595
         {
596 596
             return $this->translationParams[$name];
597 597
         }
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
      * @param bool $encoding
604 604
      * @return $this
605 605
      */
606
-    public function setURLEncoding(bool $encoding=true)
606
+    public function setURLEncoding(bool $encoding = true)
607 607
     {
608 608
         $this->requireURLEncoding();
609 609
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
      * @return $this
620 620
      * @throws Mailcode_Exception
621 621
      */
622
-    public function setURLDecoding(bool $decode=true)
622
+    public function setURLDecoding(bool $decode = true)
623 623
     {
624 624
         $this->requireURLEncoding();
625 625
 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 
631 631
     protected function requireURLEncoding() : void
632 632
     {
633
-        if($this->supportsURLEncoding()) {
633
+        if ($this->supportsURLEncoding()) {
634 634
             return;
635 635
         }
636 636
 
Please login to merge, or discard this patch.
src/Mailcode/Commands/ShowBase.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
 
71 71
     protected function validateSyntax_urldeencode() : void
72 72
     {
73
-        if($this->isURLEncoded() && $this->getURLDecodeToken() !== null)
73
+        if ($this->isURLEncoded() && $this->getURLDecodeToken() !== null)
74 74
         {
75 75
             $this->validationResult->makeError(
76 76
                 t('Cannot enable URL decoding and encoding at the same time.'),
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowVariable.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $tokens = $this->params->getInfo()->getTokens();
48 48
         $allowed = $this->resolveActiveTokens();
49 49
 
50
-        if(count($tokens) > count($allowed))
50
+        if (count($tokens) > count($allowed))
51 51
         {
52 52
             $this->validationResult->makeError(
53 53
                 t('Unknown parameters found:').' '.
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
         $allowed = array($this->getVariableToken());
70 70
 
71 71
         $token = $this->getURLEncodeToken();
72
-        if($token)
72
+        if ($token)
73 73
         {
74 74
             $allowed[] = $token;
75 75
         }
76 76
 
77 77
         $token = $this->getURLDecodeToken();
78
-        if($token)
78
+        if ($token)
79 79
         {
80 80
             $allowed[] = $token;
81 81
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/Code.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     {
92 92
         $lang = $this->params->getInfo()->getStringLiteralByIndex(0);
93 93
 
94
-        if($lang)
94
+        if ($lang)
95 95
         {
96 96
             $this->langToken = $lang;
97 97
             return;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     {
116 116
         // To keep PHPStan happy. If no token has been found, this
117 117
         // method will not be called.
118
-        if(!isset($this->langToken))
118
+        if (!isset($this->langToken))
119 119
         {
120 120
             return;
121 121
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         $name = $this->langToken->getText();
124 124
         $translator = new Mailcode_Translator();
125 125
 
126
-        if($translator->syntaxExists($name))
126
+        if ($translator->syntaxExists($name))
127 127
         {
128 128
             return;
129 129
         }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public function getSyntaxName() : string
148 148
     {
149
-        if(isset($this->langToken))
149
+        if (isset($this->langToken))
150 150
         {
151 151
             return $this->langToken->getText();
152 152
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Normalizer.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     
38 38
     public function normalize() : string
39 39
     {
40
-        if(!$this->command->isValid())
40
+        if (!$this->command->isValid())
41 41
         {
42 42
             return '';
43 43
         }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     
58 58
     private function addType() : void
59 59
     {
60
-        if(!$this->command->supportsType() || !$this->command->hasType())
60
+        if (!$this->command->supportsType() || !$this->command->hasType())
61 61
         {
62 62
             return;
63 63
         }
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
     
68 68
     private function addParams(Mailcode_Commands_Command $command) : void
69 69
     {
70
-        if(!$command->requiresParameters())
70
+        if (!$command->requiresParameters())
71 71
         {
72 72
             return;
73 73
         }
74 74
 
75
-        if($command->hasFreeformParameters())
75
+        if ($command->hasFreeformParameters())
76 76
         {
77 77
             $params = $command->getParams()->getStatementString();
78 78
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             $params = $command->getParams()->getNormalized();
82 82
         }
83 83
         
84
-        if(empty($params))
84
+        if (empty($params))
85 85
         {
86 86
             return;
87 87
         }
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
     
93 93
     private function addLogicKeywords() : void
94 94
     {
95
-        if(!$this->command->supportsLogicKeywords())
95
+        if (!$this->command->supportsLogicKeywords())
96 96
         {
97 97
             return;
98 98
         }
99 99
         
100 100
         $keywords = $this->command->getLogicKeywords()->getKeywords();
101 101
         
102
-        foreach($keywords as $keyword)
102
+        foreach ($keywords as $keyword)
103 103
         {
104 104
             $this->parts[] = ' ';
105 105
             $this->parts[] = $keyword->getKeywordString(); // e.g. "if variable"
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,8 +75,7 @@
 block discarded – undo
75 75
         if($command->hasFreeformParameters())
76 76
         {
77 77
             $params = $command->getParams()->getStatementString();
78
-        }
79
-        else
78
+        } else
80 79
         {
81 80
             $params = $command->getParams()->getNormalized();
82 81
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
         '{\s*([a-z]+)\s+([a-z-]+)\s*:([^}]*)}'
29 29
     );
30 30
     
31
-   /**
32
-    * @var Mailcode
33
-    */
31
+    /**
32
+     * @var Mailcode
33
+     */
34 34
     protected $mailcode;
35 35
     
36
-   /**
37
-    * @var Mailcode_Commands
38
-    */
36
+    /**
37
+     * @var Mailcode_Commands
38
+     */
39 39
     protected $commands;
40 40
 
41 41
     /**
@@ -49,24 +49,24 @@  discard block
 block discarded – undo
49 49
         $this->commands = $this->mailcode->getCommands();
50 50
     }
51 51
     
52
-   /**
53
-    * Gets the regex format string used to detect commands.
54
-    * 
55
-    * @return string
56
-    */
52
+    /**
53
+     * Gets the regex format string used to detect commands.
54
+     * 
55
+     * @return string
56
+     */
57 57
     protected static function getRegex() : string
58 58
     {
59 59
         return '/'.implode('|', self::COMMAND_REGEX_PARTS).'/sixU';
60 60
     }
61 61
     
62
-   /**
63
-    * Parses a string to detect all commands within. Returns a
64
-    * collection instance that contains information on all the 
65
-    * commands.
66
-    * 
67
-    * @param string $string
68
-    * @return Mailcode_Collection A collection with all unique commands found.
69
-    */
62
+    /**
63
+     * Parses a string to detect all commands within. Returns a
64
+     * collection instance that contains information on all the 
65
+     * commands.
66
+     * 
67
+     * @param string $string
68
+     * @return Mailcode_Collection A collection with all unique commands found.
69
+     */
70 70
     public function parseString(string $string) : Mailcode_Collection
71 71
     {
72 72
         $collection = new Mailcode_Collection();
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
         return preg_replace('%<style\b[^>]*>(.*?)</style>%six', '', $subject);
100 100
     }
101 101
     
102
-   /**
103
-    * Processes a single match found in the string: creates the command,
104
-    * and adds it to the collection if it's a valid command, or to the list
105
-    * of invalid commands otherwise.
106
-    * 
107
-    * @param Mailcode_Parser_Match $match
108
-    * @param Mailcode_Collection $collection
109
-    */
102
+    /**
103
+     * Processes a single match found in the string: creates the command,
104
+     * and adds it to the collection if it's a valid command, or to the list
105
+     * of invalid commands otherwise.
106
+     * 
107
+     * @param Mailcode_Parser_Match $match
108
+     * @param Mailcode_Collection $collection
109
+     */
110 110
     protected function processMatch(Mailcode_Parser_Match $match, Mailcode_Collection $collection) : void
111 111
     {
112 112
         $name = $match->getName();
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
         }
157 157
     }
158 158
     
159
-   /**
160
-    * Parses a single regex match: determines which named group
161
-    * matches, and retrieves the according information.
162
-    * 
163
-    * @param array[] $matches The regex results array.
164
-    * @param int $index The matched index.
165
-    * @return Mailcode_Parser_Match
166
-    */
159
+    /**
160
+     * Parses a single regex match: determines which named group
161
+     * matches, and retrieves the according information.
162
+     * 
163
+     * @param array[] $matches The regex results array.
164
+     * @param int $index The matched index.
165
+     * @return Mailcode_Parser_Match
166
+     */
167 167
     protected function parseMatch(array $matches, int $index) : Mailcode_Parser_Match
168 168
     {
169 169
         $name = ''; // the command name, e.g. "showvar"
@@ -201,27 +201,27 @@  discard block
 block discarded – undo
201 201
         );
202 202
     }
203 203
     
204
-   /**
205
-    * Creates an instance of the safeguard tool, which
206
-    * is used to safeguard commands in a string with placeholders.
207
-    * 
208
-    * @param string $subject The string to use to safeguard commands in.
209
-    * @return Mailcode_Parser_Safeguard
210
-    * @see Mailcode_Parser_Safeguard
211
-    */
204
+    /**
205
+     * Creates an instance of the safeguard tool, which
206
+     * is used to safeguard commands in a string with placeholders.
207
+     * 
208
+     * @param string $subject The string to use to safeguard commands in.
209
+     * @return Mailcode_Parser_Safeguard
210
+     * @see Mailcode_Parser_Safeguard
211
+     */
212 212
     public function createSafeguard(string $subject) : Mailcode_Parser_Safeguard
213 213
     {
214 214
         return new Mailcode_Parser_Safeguard($this, $subject);
215 215
     }
216 216
     
217
-   /**
218
-    * Creates a statement parser, which is used to validate arbitrary
219
-    * command statements.
220
-    * 
221
-    * @param string $statement
222
-    * @param bool $freeform
223
-    * @return Mailcode_Parser_Statement
224
-    */
217
+    /**
218
+     * Creates a statement parser, which is used to validate arbitrary
219
+     * command statements.
220
+     * 
221
+     * @param string $statement
222
+     * @param bool $freeform
223
+     * @return Mailcode_Parser_Statement
224
+     */
225 225
     public function createStatement(string $statement, bool $freeform=false) : Mailcode_Parser_Statement
226 226
     {
227 227
         return new Mailcode_Parser_Statement($statement, $freeform);
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         
79 79
         $total = count($matches[0]);
80 80
         
81
-        for($i=0; $i < $total; $i++)
81
+        for ($i = 0; $i < $total; $i++)
82 82
         {
83 83
             $match = $this->parseMatch($matches, $i);
84 84
             
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     
91 91
     protected function prepareString(string $subject) : string
92 92
     {
93
-        if(!ConvertHelper::isStringHTML($subject))
93
+        if (!ConvertHelper::isStringHTML($subject))
94 94
         {
95 95
             return $subject;
96 96
         }
@@ -140,17 +140,17 @@  discard block
 block discarded – undo
140 140
     private function handleNesting(Mailcode_Commands_Command $cmd) : void
141 141
     {
142 142
         // Set the command's parent from the stack, if any is present.
143
-        if(!empty($this->stack))
143
+        if (!empty($this->stack))
144 144
         {
145 145
             $cmd->setParent($this->stack[array_key_last($this->stack)]);
146 146
         }
147 147
 
148 148
         // Handle opening and closing commands, adding and removing from the stack.
149
-        if($cmd instanceof Mailcode_Commands_Command_Type_Opening)
149
+        if ($cmd instanceof Mailcode_Commands_Command_Type_Opening)
150 150
         {
151 151
             $this->stack[] = $cmd;
152 152
         }
153
-        else if($cmd instanceof Mailcode_Commands_Command_Type_Closing)
153
+        else if ($cmd instanceof Mailcode_Commands_Command_Type_Closing)
154 154
         {
155 155
             array_pop($this->stack);
156 156
         }
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
         // 5 = parameter type command, type
178 178
         // 6 = parameter type command, params
179 179
         
180
-        if(!empty($matches[1][$index]))
180
+        if (!empty($matches[1][$index]))
181 181
         {
182 182
             $name = $matches[1][$index];
183 183
         }
184
-        else if(!empty($matches[2][$index]))
184
+        else if (!empty($matches[2][$index]))
185 185
         {
186 186
             $name = $matches[2][$index];
187 187
             $params = $matches[3][$index];
188 188
         }
189
-        else if(!empty($matches[4][$index]))
189
+        else if (!empty($matches[4][$index]))
190 190
         {
191 191
             $name = $matches[4][$index];
192 192
             $type = $matches[5][$index];
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     * @param bool $freeform
223 223
     * @return Mailcode_Parser_Statement
224 224
     */
225
-    public function createStatement(string $statement, bool $freeform=false) : Mailcode_Parser_Statement
225
+    public function createStatement(string $statement, bool $freeform = false) : Mailcode_Parser_Statement
226 226
     {
227 227
         return new Mailcode_Parser_Statement($statement, $freeform);
228 228
     }
Please login to merge, or discard this patch.
src/Mailcode/Factory/CommandSets/Set/Misc.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     
35 35
         $this->instantiator->checkCommand($cmd);
36 36
         
37
-        if($cmd instanceof Mailcode_Commands_Command_Comment)
37
+        if ($cmd instanceof Mailcode_Commands_Command_Comment)
38 38
         {
39 39
             return $cmd;
40 40
         }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         throw $this->instantiator->exceptionUnexpectedType('Comment', $cmd);
43 43
     }
44 44
     
45
-    public function for(string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For
45
+    public function for (string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For
46 46
     {
47 47
         $sourceVariable = '$'.ltrim($sourceVariable, '$');
48 48
         $loopVariable = '$'.ltrim($loopVariable, '$');
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         
65 65
         $this->instantiator->checkCommand($cmd);
66 66
         
67
-        if($cmd instanceof Mailcode_Commands_Command_For)
67
+        if ($cmd instanceof Mailcode_Commands_Command_For)
68 68
         {
69 69
             return $cmd;
70 70
         }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         $this->instantiator->checkCommand($cmd);
91 91
 
92
-        if($cmd instanceof Mailcode_Commands_Command_Code)
92
+        if ($cmd instanceof Mailcode_Commands_Command_Code)
93 93
         {
94 94
             return $cmd;
95 95
         }
Please login to merge, or discard this patch.
src/Mailcode/Factory/Instantiator.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class Mailcode_Factory_Instantiator
22 22
 {
23
-    public function buildIf(string $ifType, string $params, string $type='') : Mailcode_Commands_IfBase
23
+    public function buildIf(string $ifType, string $params, string $type = '') : Mailcode_Commands_IfBase
24 24
     {
25 25
         $stringType = $type;
26 26
         
27
-        if(!empty($type))
27
+        if (!empty($type))
28 28
         {
29 29
             $stringType = ' '.$type;
30 30
         }
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         
44 44
         $this->checkCommand($command);
45 45
         
46
-        if($command instanceof Mailcode_Commands_IfBase)
46
+        if ($command instanceof Mailcode_Commands_IfBase)
47 47
         {
48 48
             return $command;
49 49
         }
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
         throw $this->exceptionUnexpectedType('IfBase', $command);
52 52
     }
53 53
     
54
-    public function buildIfVar(string $ifType, string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_IfBase
54
+    public function buildIfVar(string $ifType, string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_IfBase
55 55
     {
56
-        if($quoteValue)
56
+        if ($quoteValue)
57 57
         {
58 58
             $value = $this->quoteString($value);
59 59
         }
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
     * @param bool $caseInsensitive
86 86
     * @return Mailcode_Commands_IfBase
87 87
     */
88
-    public function buildIfContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_IfBase
88
+    public function buildIfContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false) : Mailcode_Commands_IfBase
89 89
     {
90 90
         $keyword = ' ';
91 91
         
92
-        if($caseInsensitive)
92
+        if ($caseInsensitive)
93 93
         {
94 94
             $keyword = ' '.Mailcode_Commands_Keywords::TYPE_INSENSITIVE;
95 95
         }
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
         return $this->buildIf($ifType, $condition, 'contains');
105 105
     }
106 106
     
107
-    public function buildIfBeginsWith(string $ifType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase
107
+    public function buildIfBeginsWith(string $ifType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase
108 108
     {
109 109
         return $this->buildIfSearch($ifType, 'begins-with', $variable, $search, $caseInsensitive);
110 110
     }
111 111
     
112
-    public function buildIfEndsWith(string $ifType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase
112
+    public function buildIfEndsWith(string $ifType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase
113 113
     {
114 114
         return $this->buildIfSearch($ifType, 'ends-with', $variable, $search, $caseInsensitive);
115 115
     }
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
         );
160 160
     }
161 161
 
162
-    private function buildIfSearch(string $ifType, string $subType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase
162
+    private function buildIfSearch(string $ifType, string $subType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase
163 163
     {
164 164
         $keyword = ' ';
165 165
         
166
-        if($caseInsensitive)
166
+        if ($caseInsensitive)
167 167
         {
168 168
             $keyword = ' '.Mailcode_Commands_Keywords::TYPE_INSENSITIVE;
169 169
         }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     
193 193
     public function checkCommand(Mailcode_Commands_Command $command) : void
194 194
     {
195
-        if($command->isValid())
195
+        if ($command->isValid())
196 196
         {
197 197
             return;
198 198
         }
Please login to merge, or discard this patch.
src/Mailcode/Interfaces/Commands/URLDecode.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,5 +12,5 @@
 block discarded – undo
12 12
      * @param bool $decode
13 13
      * @return $this
14 14
      */
15
-    public function setURLDecoding(bool $decode=true);
15
+    public function setURLDecoding(bool $decode = true);
16 16
 }
Please login to merge, or discard this patch.