Passed
Push — master ( acb001...8c805d )
by Sebastian
03:51
created
src/Mailcode/Parser/Statement/Tokenizer/Process/Operands.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@
 block discarded – undo
25 25
 
26 26
     protected function _process() : void
27 27
     {
28
-        foreach($this->operands as $operand)
28
+        foreach ($this->operands as $operand)
29 29
         {
30
-            if(strstr($this->tokenized, $operand))
30
+            if (strstr($this->tokenized, $operand))
31 31
             {
32 32
                 $this->registerToken('Operand', $operand);
33 33
             }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement/Tokenizer/Process/Variables.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
     {
11 11
         $vars = Mailcode::create()->findVariables($this->tokenized)->getGroupedByHash();
12 12
 
13
-        foreach($vars as $var)
13
+        foreach ($vars as $var)
14 14
         {
15 15
             $this->registerToken('Variable', $var->getMatchedText(), $var);
16 16
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement/Tokenizer/Process/Numbers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
         $matches = array();
12 12
         preg_match_all('/-*[0-9]+\s*[.,]\s*[0-9]+|-*[0-9]+/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER);
13 13
 
14
-        foreach($matches[0] as $match)
14
+        foreach ($matches[0] as $match)
15 15
         {
16 16
             $this->registerToken('Number', $match);
17 17
         }
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
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         
81 81
         $total = count($matches[0]);
82 82
         
83
-        for($i=0; $i < $total; $i++)
83
+        for ($i = 0; $i < $total; $i++)
84 84
         {
85 85
             $match = $this->parseMatch($matches, $i);
86 86
             
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     
93 93
     protected function prepareString(string $subject) : string
94 94
     {
95
-        if(!ConvertHelper::isStringHTML($subject))
95
+        if (!ConvertHelper::isStringHTML($subject))
96 96
         {
97 97
             return $subject;
98 98
         }
@@ -142,17 +142,17 @@  discard block
 block discarded – undo
142 142
     private function handleNesting(Mailcode_Commands_Command $cmd) : void
143 143
     {
144 144
         // Set the command's parent from the stack, if any is present.
145
-        if(!empty($this->stack))
145
+        if (!empty($this->stack))
146 146
         {
147 147
             $cmd->setParent($this->getStackLast());
148 148
         }
149 149
 
150 150
         // Handle opening and closing commands, adding and removing from the stack.
151
-        if($cmd instanceof Mailcode_Commands_Command_Type_Opening)
151
+        if ($cmd instanceof Mailcode_Commands_Command_Type_Opening)
152 152
         {
153 153
             $this->stack[] = $cmd;
154 154
         }
155
-        else if($cmd instanceof Mailcode_Commands_Command_Type_Closing)
155
+        else if ($cmd instanceof Mailcode_Commands_Command_Type_Closing)
156 156
         {
157 157
             array_pop($this->stack);
158 158
         }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     {
163 163
         $cmd = $this->stack[array_key_last($this->stack)];
164 164
 
165
-        if($cmd instanceof Mailcode_Commands_Command)
165
+        if ($cmd instanceof Mailcode_Commands_Command)
166 166
         {
167 167
             return $cmd;
168 168
         }
@@ -191,16 +191,16 @@  discard block
 block discarded – undo
191 191
         // 5 = parameter type command, type
192 192
         // 6 = parameter type command, params
193 193
         
194
-        if(!empty($matches[1][$index]))
194
+        if (!empty($matches[1][$index]))
195 195
         {
196 196
             $name = $matches[1][$index];
197 197
         }
198
-        else if(!empty($matches[2][$index]))
198
+        else if (!empty($matches[2][$index]))
199 199
         {
200 200
             $name = $matches[2][$index];
201 201
             $params = $matches[3][$index];
202 202
         }
203
-        else if(!empty($matches[4][$index]))
203
+        else if (!empty($matches[4][$index]))
204 204
         {
205 205
             $name = $matches[4][$index];
206 206
             $type = $matches[5][$index];
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
     * @param bool $freeform
237 237
     * @return Mailcode_Parser_Statement
238 238
     */
239
-    public function createStatement(string $statement, bool $freeform=false) : Mailcode_Parser_Statement
239
+    public function createStatement(string $statement, bool $freeform = false) : Mailcode_Parser_Statement
240 240
     {
241 241
         return new Mailcode_Parser_Statement($statement, $freeform);
242 242
     }
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/ProtectedContent.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
     public function protectContent(string $string, Mailcode_Parser_Safeguard_Placeholder $open, Mailcode_Parser_Safeguard_Placeholder $end) : string
35 35
     {
36
-        if(!$end->getCommand() instanceof Mailcode_Commands_Command_End)
36
+        if (!$end->getCommand() instanceof Mailcode_Commands_Command_End)
37 37
         {
38 38
             throw new Mailcode_Exception(
39 39
                 'Invalid commands nesting',
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         $start = strpos($string, $open->getReplacementText()) + $open->getReplacementLength();
46 46
         $end = strpos($string, $end->getReplacementText());
47 47
 
48
-        $content = substr($string, $start, ($end-$start));
48
+        $content = substr($string, $start, ($end - $start));
49 49
 
50 50
         return $this->replaceContent($string, $content);
51 51
     }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Placeholder.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     
70 70
     public function getReplacementText() : string
71 71
     {
72
-        if(!empty($this->replacement))
72
+        if (!empty($this->replacement))
73 73
         {
74 74
             return $this->replacement;
75 75
         }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         // to total amount of zeroes to pad with to obtain the total length
88 88
         $padLength = $this->getLength() - $length - 1; // -1 for the ID separator char
89 89
         
90
-        if($padLength < 0) 
90
+        if ($padLength < 0) 
91 91
         {
92 92
             $padLength = 0;
93 93
         }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         // separator, there is no ambiguity. It becomes "1*000000000" and
105 105
         // "10*00000000", keeping the ID intact.
106 106
 
107
-        $paddedID  = str_pad((string)$this->id.'*', $padLength, '0');
107
+        $paddedID = str_pad((string)$this->id.'*', $padLength, '0');
108 108
         
109 109
         $this->replacement = sprintf($format, $paddedID);
110 110
 
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     */
139 139
     public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard
140 140
     {
141
-        if(empty($delimiter))
141
+        if (empty($delimiter))
142 142
         {
143 143
             throw new Mailcode_Exception(
144 144
                 'Empty delimiter',
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             );
148 148
         }
149 149
 
150
-        if(!preg_match('/\A[^0-9*].*[^0-9*]\z/x', $delimiter))
150
+        if (!preg_match('/\A[^0-9*].*[^0-9*]\z/x', $delimiter))
151 151
         {
152 152
             throw new Mailcode_Exception(
153 153
                 'The delimiter may not begin or end with a number.',
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             );
157 157
         }
158 158
 
159
-        if(strstr($delimiter, '*') !== false)
159
+        if (strstr($delimiter, '*') !== false)
160 160
         {
161 161
             throw new Mailcode_Exception(
162 162
                 'The delimiter may not contain the * character.',
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         $placeholders = $this->getPlaceholders();
207 207
         $string = $this->originalString;
208 208
         
209
-        foreach($placeholders as $placeholder)
209
+        foreach ($placeholders as $placeholder)
210 210
         {
211 211
             $string = $this->makePlaceholderSafe($string, $placeholder);
212 212
         }
@@ -236,14 +236,14 @@  discard block
 block discarded – undo
236 236
         $placeholders = $this->getPlaceholders();
237 237
         $total = count($placeholders);
238 238
 
239
-        for($i=0; $i < $total; $i++)
239
+        for ($i = 0; $i < $total; $i++)
240 240
         {
241 241
             $placeholder = $placeholders[$i];
242 242
             $command = $placeholder->getCommand();
243 243
 
244
-            if($command instanceof Mailcode_Interfaces_Commands_ProtectedContent)
244
+            if ($command instanceof Mailcode_Interfaces_Commands_ProtectedContent)
245 245
             {
246
-                $string = $command->protectContent($string, $placeholder, $placeholders[$i+1]);
246
+                $string = $command->protectContent($string, $placeholder, $placeholders[$i + 1]);
247 247
             }
248 248
         }
249 249
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
     {
255 255
         $pos = mb_strpos($string, $placeholder->getOriginalText());
256 256
 
257
-        if($pos === false)
257
+        if ($pos === false)
258 258
         {
259 259
             throw new Mailcode_Exception(
260 260
                 'Placeholder original text not found',
@@ -286,23 +286,23 @@  discard block
 block discarded – undo
286 286
 
287 287
         $placeholders = $this->getPlaceholders();
288 288
 
289
-        foreach($urls as $url)
289
+        foreach ($urls as $url)
290 290
         {
291
-            if(stristr($url, 'tel:'))
291
+            if (stristr($url, 'tel:'))
292 292
             {
293 293
                 continue;
294 294
             }
295 295
 
296
-            foreach($placeholders as $placeholder)
296
+            foreach ($placeholders as $placeholder)
297 297
             {
298 298
                 $command = $placeholder->getCommand();
299 299
 
300
-                if(!$command->supportsURLEncoding())
300
+                if (!$command->supportsURLEncoding())
301 301
                 {
302 302
                     continue;
303 303
                 }
304 304
 
305
-                if(strstr($url, $placeholder->getReplacementText()) && !$command->isURLDecoded())
305
+                if (strstr($url, $placeholder->getReplacementText()) && !$command->isURLDecoded())
306 306
                 {
307 307
                     $command->setURLEncoding(true);
308 308
                 }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     */
320 320
     public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting
321 321
     {
322
-        if(is_string($subject))
322
+        if (is_string($subject))
323 323
         {
324 324
             $subject = Mailcode::create()->createString($subject);
325 325
         }
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
     */
336 336
     public function getPlaceholders()
337 337
     {
338
-        if(isset($this->placeholders))
338
+        if (isset($this->placeholders))
339 339
         {
340 340
             return $this->placeholders;
341 341
         }
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
         
345 345
         $cmds = $this->getCollection()->getCommands();
346 346
         
347
-        foreach($cmds as $command)
347
+        foreach ($cmds as $command)
348 348
         {
349 349
             self::$counter++;
350 350
             
@@ -365,21 +365,21 @@  discard block
 block discarded – undo
365 365
      * @return string
366 366
      * @throws Mailcode_Exception
367 367
      */
368
-    protected function restore(string $string, bool $partial=false, bool $highlighted=false) : string
368
+    protected function restore(string $string, bool $partial = false, bool $highlighted = false) : string
369 369
     {
370
-        if(!$partial)
370
+        if (!$partial)
371 371
         {
372 372
             $this->requireValidCollection();
373 373
         }
374 374
         
375 375
         $formatting = $this->createFormatting($string);
376 376
 
377
-        if($partial)
377
+        if ($partial)
378 378
         {
379 379
             $formatting->makePartial();
380 380
         }
381 381
         
382
-        if($highlighted)
382
+        if ($highlighted)
383 383
         {
384 384
             $formatting->replaceWithHTMLHighlighting();
385 385
         }
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
         {
400 400
             $command = $placeholder->getCommand();
401 401
 
402
-            if($command instanceof Mailcode_Interfaces_Commands_ProtectedContent)
402
+            if ($command instanceof Mailcode_Interfaces_Commands_ProtectedContent)
403 403
             {
404 404
                 $string = $command->restoreContent($string);
405 405
             }
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
     */
493 493
     public function getCollection() : Mailcode_Collection
494 494
     {
495
-        if(isset($this->collection))
495
+        if (isset($this->collection))
496 496
         {
497 497
             return $this->collection;
498 498
         }
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
     */
515 515
     protected function requireValidCollection() : void
516 516
     {
517
-        if($this->getCollection()->isValid())
517
+        if ($this->getCollection()->isValid())
518 518
         {
519 519
             return;
520 520
         }
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
     */
538 538
     public function getPlaceholderStrings() : array
539 539
     {
540
-        if(is_array($this->placeholderStrings))
540
+        if (is_array($this->placeholderStrings))
541 541
         {
542 542
             return $this->placeholderStrings;
543 543
         }
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
         
547 547
         $this->placeholderStrings = array();
548 548
         
549
-        foreach($placeholders as $placeholder)
549
+        foreach ($placeholders as $placeholder)
550 550
         {
551 551
             $this->placeholderStrings[] = $placeholder->getReplacementText();
552 552
         }
@@ -572,9 +572,9 @@  discard block
 block discarded – undo
572 572
     {
573 573
         $placeholders = $this->getPlaceholders();
574 574
         
575
-        foreach($placeholders as $placeholder)
575
+        foreach ($placeholders as $placeholder)
576 576
         {
577
-            if($placeholder->getID() === $id)
577
+            if ($placeholder->getID() === $id)
578 578
             {
579 579
                 return $placeholder;
580 580
             }
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
     {
602 602
         $placeholders = $this->getPlaceholders();
603 603
         
604
-        foreach($placeholders as $placeholder)
604
+        foreach ($placeholders as $placeholder)
605 605
         {
606
-            if($placeholder->getReplacementText() === $string)
606
+            if ($placeholder->getReplacementText() === $string)
607 607
             {
608 608
                 return $placeholder;
609 609
             }
Please login to merge, or discard this patch.