Passed
Push — master ( acaf2a...2147dc )
by Sebastian
02:19
created
src/Mailcode/Parser/Safeguard.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     */
127 127
     public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard
128 128
     {
129
-        if(empty($delimiter))
129
+        if (empty($delimiter))
130 130
         {
131 131
             throw new Mailcode_Exception(
132 132
                 'Empty delimiter',
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
         $placeholders = $this->getPlaceholders();
177 177
         $string = $this->originalString;
178 178
         
179
-        foreach($placeholders as $placeholder)
179
+        foreach ($placeholders as $placeholder)
180 180
         {
181 181
             $pos = mb_strpos($string, $placeholder->getOriginalText());
182 182
             
183
-            if($pos === false)
183
+            if ($pos === false)
184 184
             {
185 185
                 throw new Mailcode_Exception(
186 186
                     'Placeholder original text not found',
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     */
210 210
     public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting
211 211
     {
212
-        if(is_string($subject))
212
+        if (is_string($subject))
213 213
         {
214 214
             $subject = Mailcode::create()->createString($subject);
215 215
         }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     */
226 226
     public function getPlaceholders()
227 227
     {
228
-        if(isset($this->placeholders))
228
+        if (isset($this->placeholders))
229 229
         {
230 230
             return $this->placeholders;
231 231
         }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
         
235 235
         $cmds = $this->getCollection()->getCommands();
236 236
         
237
-        foreach($cmds as $command)
237
+        foreach ($cmds as $command)
238 238
         {
239 239
             self::$counter++;
240 240
             
@@ -248,21 +248,21 @@  discard block
 block discarded – undo
248 248
         return $this->placeholders;
249 249
     }
250 250
     
251
-    protected function restore(string $string, bool $partial=false, bool $highlighted=false) : string
251
+    protected function restore(string $string, bool $partial = false, bool $highlighted = false) : string
252 252
     {
253
-        if(!$partial)
253
+        if (!$partial)
254 254
         {
255 255
             $this->requireValidCollection();
256 256
         }
257 257
         
258 258
         $formatting = $this->createFormatting($string);
259 259
 
260
-        if($partial)
260
+        if ($partial)
261 261
         {
262 262
             $formatting->makePartial();
263 263
         }
264 264
         
265
-        if($highlighted)
265
+        if ($highlighted)
266 266
         {
267 267
             $formatting->replaceWithHTMLHighlighting();
268 268
         }
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
     */
359 359
     public function getCollection() : Mailcode_Collection
360 360
     {
361
-        if(isset($this->collection))
361
+        if (isset($this->collection))
362 362
         {
363 363
             return $this->collection;
364 364
         }
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
     */
381 381
     protected function requireValidCollection() : void
382 382
     {
383
-        if($this->getCollection()->isValid())
383
+        if ($this->getCollection()->isValid())
384 384
         {
385 385
             return;
386 386
         }
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
     */
404 404
     public function getPlaceholderStrings() : array
405 405
     {
406
-        if(is_array($this->placeholderStrings))
406
+        if (is_array($this->placeholderStrings))
407 407
         {
408 408
             return $this->placeholderStrings;
409 409
         }
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
         
413 413
         $this->placeholderStrings = array();
414 414
         
415
-        foreach($placeholders as $placeholder)
415
+        foreach ($placeholders as $placeholder)
416 416
         {
417 417
             $this->placeholderStrings[] = $placeholder->getReplacementText();
418 418
         }
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
     {
439 439
         $placeholders = $this->getPlaceholders();
440 440
         
441
-        foreach($placeholders as $placeholder)
441
+        foreach ($placeholders as $placeholder)
442 442
         {
443
-            if($placeholder->getID() === $id)
443
+            if ($placeholder->getID() === $id)
444 444
             {
445 445
                 return $placeholder;
446 446
             }
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
     {
468 468
         $placeholders = $this->getPlaceholders();
469 469
         
470
-        foreach($placeholders as $placeholder)
470
+        foreach ($placeholders as $placeholder)
471 471
         {
472
-            if($placeholder->getReplacementText() === $string)
472
+            if ($placeholder->getReplacementText() === $string)
473 473
             {
474 474
                 return $placeholder;
475 475
             }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowVariable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
     {
72 72
         $tokens = $this->params->getInfo()->getTokens();
73 73
 
74
-        if(count($tokens) > 1)
74
+        if (count($tokens) > 1)
75 75
         {
76 76
             $this->validationResult->makeError(
77 77
                 t('Unknown parameters found:').' '.
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
             }
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
     {
263 263
         $result = array();
264 264
 
265
-        foreach($this->commands as $command)
265
+        foreach ($this->commands as $command)
266 266
         {
267
-            if($command instanceof $className)
267
+            if ($command instanceof $className)
268 268
             {
269 269
                 $result[] = $command;
270 270
             }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     {
278 278
         $commands = $this->getCommands();
279 279
         
280
-        if(!empty($commands))
280
+        if (!empty($commands))
281 281
         {
282 282
             return array_shift($commands);
283 283
         }
Please login to merge, or discard this patch.
src/Mailcode/Translator/Syntax/ApacheVelocity/ShowDate.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $internalFormat = $command->getTranslationParam('internal_format');
54 54
 
55
-        if(empty($internalFormat))
55
+        if (empty($internalFormat))
56 56
         {
57 57
             $internalFormat = self::DEFAULT_INTERNAL_FORMAT;
58 58
         }
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
         $chars = ConvertHelper::string2array($formatString);
71 71
         $result = array();
72 72
         
73
-        foreach($chars as $char)
73
+        foreach ($chars as $char)
74 74
         {
75
-            if(!isset($this->charTable[$char]))
75
+            if (!isset($this->charTable[$char]))
76 76
             {
77 77
                 throw new Mailcode_Translator_Exception(
78 78
                     'Unknown date format string character',
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     protected $parent = null;
111 111
 
112
-    public function __construct(string $type='', string $paramsString='', string $matchedText='')
112
+    public function __construct(string $type = '', string $paramsString = '', string $matchedText = '')
113 113
     {
114 114
         $this->type = $type;
115 115
         $this->paramsString = html_entity_decode($paramsString);
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     {
206 206
         $this->requireNonDummy();
207 207
         
208
-        if($this->hash === '') {
208
+        if ($this->hash === '') {
209 209
             $this->hash = md5($this->matchedText);
210 210
         }
211 211
         
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
     
215 215
     protected function requireNonDummy() : void
216 216
     {
217
-        if(!$this->isDummy())
217
+        if (!$this->isDummy())
218 218
         {
219 219
             return;
220 220
         }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     
234 234
     protected function validate() : \AppUtils\OperationResult
235 235
     {
236
-        if(!$this->validated)
236
+        if (!$this->validated)
237 237
         {
238 238
             $this->requireNonDummy();
239 239
             $this->validateSyntax();
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
     
247 247
     public function getValidationResult() :  \AppUtils\OperationResult
248 248
     {
249
-        if(isset($this->validationResult)) 
249
+        if (isset($this->validationResult)) 
250 250
         {
251 251
             return $this->validationResult;
252 252
         }
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
     {
263 263
         $validations = array_merge($this->validations, $this->getValidations());
264 264
         
265
-        foreach($validations as $validation)
265
+        foreach ($validations as $validation)
266 266
         {
267 267
             // break off at the first validation issue
268
-            if(!$this->validateSyntaxMethod($validation))
268
+            if (!$this->validateSyntaxMethod($validation))
269 269
             {
270 270
                 return;
271 271
             }
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
     {
277 277
         $method = 'validateSyntax_'.$validation;
278 278
         
279
-        if(!method_exists($this, $method))
279
+        if (!method_exists($this, $method))
280 280
         {
281 281
             throw new Mailcode_Exception(
282 282
                 'Missing validation method ['.$validation.']',
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
     
302 302
     protected function validateSyntax_params_empty() : void
303 303
     {
304
-        if(!$this->requiresParameters())
304
+        if (!$this->requiresParameters())
305 305
         {
306 306
             return;
307 307
         }
308 308
         
309
-        if(empty($this->paramsString))
309
+        if (empty($this->paramsString))
310 310
         {
311 311
             $this->validationResult->makeError(
312 312
                 t('Parameters have to be specified.'),
@@ -318,14 +318,14 @@  discard block
 block discarded – undo
318 318
     
319 319
     protected function validateSyntax_params_keywords() : void
320 320
     {
321
-        if(!$this->supportsLogicKeywords())
321
+        if (!$this->supportsLogicKeywords())
322 322
         {
323 323
             return;
324 324
         }
325 325
         
326 326
         $this->logicKeywords = new Mailcode_Commands_LogicKeywords($this, $this->paramsString);
327 327
         
328
-        if(!$this->logicKeywords->isValid())
328
+        if (!$this->logicKeywords->isValid())
329 329
         {
330 330
             $this->validationResult->makeError(
331 331
                 t('Invalid parameters:').' '.$this->logicKeywords->getErrorMessage(),
@@ -340,14 +340,14 @@  discard block
 block discarded – undo
340 340
     
341 341
     protected function validateSyntax_params_parse() : void
342 342
     {
343
-        if(!$this->requiresParameters())
343
+        if (!$this->requiresParameters())
344 344
         {
345 345
             return;
346 346
         }
347 347
         
348 348
         $this->params = $this->mailcode->getParser()->createStatement($this->paramsString);
349 349
         
350
-        if(!$this->params->isValid())
350
+        if (!$this->params->isValid())
351 351
         {
352 352
             $error = $this->params->getValidationResult();
353 353
             
@@ -364,14 +364,14 @@  discard block
 block discarded – undo
364 364
     
365 365
     protected function validateSyntax_type_supported() : void
366 366
     {
367
-        if(!$this->supportsType() || empty($this->type))
367
+        if (!$this->supportsType() || empty($this->type))
368 368
         {
369 369
             return;
370 370
         }
371 371
         
372 372
         $types = $this->getSupportedTypes();
373 373
 
374
-        if(!in_array($this->type, $types))
374
+        if (!in_array($this->type, $types))
375 375
         {
376 376
             $this->validationResult->makeError(
377 377
                 t('The command addon %1$s is not supported.', $this->type).' '.
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
     
386 386
     protected function validateSyntax_type_unsupported() : void
387 387
     {
388
-        if($this->supportsType() || empty($this->type))
388
+        if ($this->supportsType() || empty($this->type))
389 389
         {
390 390
             return;
391 391
         }
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
     
404 404
     public function getType() : string
405 405
     {
406
-        if($this->supportsType())
406
+        if ($this->supportsType())
407 407
         {
408 408
             return $this->type;
409 409
         }
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
     
424 424
     public function getHighlighted() : string
425 425
     {
426
-        if(!$this->isValid())
426
+        if (!$this->isValid())
427 427
         {
428 428
             return '';
429 429
         }
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
     
435 435
     public function getParamsString() : string
436 436
     {
437
-        if($this->requiresParameters())
437
+        if ($this->requiresParameters())
438 438
         {
439 439
             return $this->paramsString;
440 440
         }
@@ -469,22 +469,22 @@  discard block
 block discarded – undo
469 469
     
470 470
     public final function getCommandType() : string
471 471
     {
472
-        if($this instanceof Mailcode_Commands_Command_Type_Closing)
472
+        if ($this instanceof Mailcode_Commands_Command_Type_Closing)
473 473
         {
474 474
             return 'Closing';
475 475
         }
476 476
         
477
-        if($this instanceof Mailcode_Commands_Command_Type_Opening)
477
+        if ($this instanceof Mailcode_Commands_Command_Type_Opening)
478 478
         {
479 479
             return 'Opening';
480 480
         }
481 481
         
482
-        if($this instanceof Mailcode_Commands_Command_Type_Sibling)
482
+        if ($this instanceof Mailcode_Commands_Command_Type_Sibling)
483 483
         {
484 484
             return 'Sibling';
485 485
         }
486 486
         
487
-        if($this instanceof Mailcode_Commands_Command_Type_Standalone)
487
+        if ($this instanceof Mailcode_Commands_Command_Type_Standalone)
488 488
         {
489 489
             return 'Standalone';
490 490
         }
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
     
535 535
     public function getLogicKeywords() : Mailcode_Commands_LogicKeywords
536 536
     {
537
-        if($this->supportsLogicKeywords() && isset($this->logicKeywords))
537
+        if ($this->supportsLogicKeywords() && isset($this->logicKeywords))
538 538
         {
539 539
             return $this->logicKeywords;
540 540
         }
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
     */
569 569
     public function getTranslationParam(string $name)
570 570
     {
571
-        if(isset($this->translationParams[$name]))
571
+        if (isset($this->translationParams[$name]))
572 572
         {
573 573
             return $this->translationParams[$name];
574 574
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser.php 1 patch
Spacing   +10 added lines, -10 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
         }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     {
112 112
         $name = $match->getName();
113 113
         
114
-        if(!$this->commands->nameExists($name))
114
+        if (!$this->commands->nameExists($name))
115 115
         {
116 116
             $collection->addErrorMessage(
117 117
                 $match->getMatchedString(),
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
             $match->getMatchedString()
129 129
         );
130 130
         
131
-        if(!$cmd->isValid())
131
+        if (!$cmd->isValid())
132 132
         {
133 133
             $collection->addInvalidCommand($cmd);
134 134
             return;
@@ -137,17 +137,17 @@  discard block
 block discarded – undo
137 137
         $collection->addCommand($cmd);
138 138
 
139 139
         // Set the command's parent from the stack, if any is present.
140
-        if(!empty($this->stack))
140
+        if (!empty($this->stack))
141 141
         {
142 142
             $cmd->setParent($this->stack[array_key_last($this->stack)]);
143 143
         }
144 144
 
145 145
         // Handle opening and closing commands, adding and removing from the stack.
146
-        if($cmd instanceof Mailcode_Commands_Command_Type_Opening)
146
+        if ($cmd instanceof Mailcode_Commands_Command_Type_Opening)
147 147
         {
148 148
             $this->stack[] = $cmd;
149 149
         }
150
-        else if($cmd instanceof Mailcode_Commands_Command_Type_Closing)
150
+        else if ($cmd instanceof Mailcode_Commands_Command_Type_Closing)
151 151
         {
152 152
             array_pop($this->stack);
153 153
         }
@@ -174,16 +174,16 @@  discard block
 block discarded – undo
174 174
         // 5 = parameter type command, type
175 175
         // 6 = parameter type command, params
176 176
         
177
-        if(!empty($matches[1][$index]))
177
+        if (!empty($matches[1][$index]))
178 178
         {
179 179
             $name = $matches[1][$index];
180 180
         }
181
-        else if(!empty($matches[2][$index]))
181
+        else if (!empty($matches[2][$index]))
182 182
         {
183 183
             $name = $matches[2][$index];
184 184
             $params = $matches[3][$index];
185 185
         }
186
-        else if(!empty($matches[4][$index]))
186
+        else if (!empty($matches[4][$index]))
187 187
         {
188 188
             $name = $matches[4][$index];
189 189
             $type = $matches[5][$index];
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/Validation/Variable.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     {
34 34
         $var = $this->validator->createVariable();
35 35
         
36
-        if($var->isValid())
36
+        if ($var->isValid())
37 37
         {
38 38
             $this->variableToken = $var->getToken();
39 39
         }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     */
54 54
     public function getVariable() : Mailcode_Variables_Variable
55 55
     {
56
-        if($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
56
+        if ($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
57 57
         {
58 58
             return $this->variableToken->getVariable();
59 59
         }
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
     {
102 102
         $parent = $subject->getParent();
103 103
 
104
-        if($parent === null)
104
+        if ($parent === null)
105 105
         {
106 106
             return null;
107 107
         }
108 108
 
109
-        if($parent instanceof Mailcode_Commands_Command_For)
109
+        if ($parent instanceof Mailcode_Commands_Command_For)
110 110
         {
111 111
             return $parent;
112 112
         }
Please login to merge, or discard this patch.