Passed
Push — master ( acb001...8c805d )
by Sebastian
03:51
created
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.