Passed
Push — master ( eafb24...c53bf4 )
by Sebastian
04:30
created
src/Mailcode/Parser/Safeguard/Formatter.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
  */
25 25
 abstract class Mailcode_Parser_Safeguard_Formatter
26 26
 {
27
-   /**
28
-    * @var Mailcode_Parser_Safeguard
29
-    */
27
+    /**
28
+     * @var Mailcode_Parser_Safeguard
29
+     */
30 30
     protected $safeguard;
31 31
     
32 32
     public function __construct(Mailcode_Parser_Safeguard $safeguard)
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
     
37 37
     abstract public function format(string $subject) : string;
38 38
     
39
-   /**
40
-    * Resolves a list of positions of needle in the haystack.
41
-    * 
42
-    * @param string $needle
43
-    * @param string $haystack
44
-    * @return int[]
45
-    */
39
+    /**
40
+     * Resolves a list of positions of needle in the haystack.
41
+     * 
42
+     * @param string $needle
43
+     * @param string $haystack
44
+     * @return int[]
45
+     */
46 46
     protected function resolvePositions(string $needle, string $haystack) : array
47 47
     {
48 48
         $lastPos = 0;
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
         return $positions;
58 58
     }
59 59
     
60
-   /**
61
-    * Resolves the newline character used in the string.
62
-    * 
63
-    * @param string $subject
64
-    * @return string
65
-    */
60
+    /**
61
+     * Resolves the newline character used in the string.
62
+     * 
63
+     * @param string $subject
64
+     * @return string
65
+     */
66 66
     protected function resolveNewlineChar(string $subject) : string
67 67
     {
68 68
         $eol = ConvertHelper::detectEOLCharacter($subject);
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
         return PHP_EOL;
76 76
     }
77 77
     
78
-   /**
79
-    * Resolves the list of placeholder strings that need
80
-    * to be formatted. This includes only commands that
81
-    * do not generate content.
82
-    *  
83
-    * @return string[]
84
-    */
78
+    /**
79
+     * Resolves the list of placeholder strings that need
80
+     * to be formatted. This includes only commands that
81
+     * do not generate content.
82
+     *  
83
+     * @return string[]
84
+     */
85 85
     protected function resolvePlaceholderStrings() : array
86 86
     {
87 87
         $placeholders = $this->filterPlaceholders();
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
         return $result;
97 97
     }
98 98
     
99
-   /**
100
-    * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
101
-    */
99
+    /**
100
+     * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
101
+     */
102 102
     protected function filterPlaceholders()
103 103
     {
104 104
         return $this->safeguard->getPlaceholders();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         $lastPos = 0;
49 49
         $positions = array();
50 50
         
51
-        while (($lastPos = mb_strpos($haystack, $needle, $lastPos))!== false)
51
+        while (($lastPos = mb_strpos($haystack, $needle, $lastPos)) !== false)
52 52
         {
53 53
             $positions[] = $lastPos;
54 54
             $lastPos = $lastPos + mb_strlen($needle);
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     {
68 68
         $eol = ConvertHelper::detectEOLCharacter($subject);
69 69
         
70
-        if($eol)
70
+        if ($eol)
71 71
         {
72 72
             return $eol->getCharacter();
73 73
         }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         
89 89
         $result = array();
90 90
         
91
-        foreach($placeholders as $placeholder)
91
+        foreach ($placeholders as $placeholder)
92 92
         {
93 93
             $result[] = $placeholder->getReplacementText();
94 94
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/SingleLines/Placeholder.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -21,39 +21,39 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class Mailcode_Parser_Safeguard_Formatter_SingleLines_Placeholder
23 23
 {
24
-   /**
25
-    * @var int
26
-    */
24
+    /**
25
+     * @var int
26
+     */
27 27
     protected $eolLength;
28 28
     
29
-   /**
30
-    * @var int
31
-    */
29
+    /**
30
+     * @var int
31
+     */
32 32
     protected $position;
33 33
 
34
-   /**
35
-    * @var string
36
-    */
34
+    /**
35
+     * @var string
36
+     */
37 37
     protected $subject;
38 38
     
39
-   /**
40
-    * @var Mailcode_Parser_Safeguard_Formatter_SingleLines
41
-    */
39
+    /**
40
+     * @var Mailcode_Parser_Safeguard_Formatter_SingleLines
41
+     */
42 42
     protected $formatter;
43 43
     
44
-   /**
45
-    * @var boolean
46
-    */
44
+    /**
45
+     * @var boolean
46
+     */
47 47
     protected $prepend = false;
48 48
 
49
-   /**
50
-    * @var boolean
51
-    */
49
+    /**
50
+     * @var boolean
51
+     */
52 52
     protected $append = false;
53 53
     
54
-   /**
55
-    * @var int
56
-    */
54
+    /**
55
+     * @var int
56
+     */
57 57
     protected $placeholderLength;
58 58
     
59 59
     public function __construct(Mailcode_Parser_Safeguard_Formatter_SingleLines $formatter, string $subject, int $placeholderLength, int $position)
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
         $this->analyzeAppend($subject);
68 68
     }
69 69
     
70
-   /**
71
-    * Whether an EOL character needs to be appended or prepended.
72
-    *  
73
-    * @return bool
74
-    */
70
+    /**
71
+     * Whether an EOL character needs to be appended or prepended.
72
+     *  
73
+     * @return bool
74
+     */
75 75
     public function requiresAdjustment() : bool
76 76
     {
77 77
         return $this->requiresAppend() || $this->requiresPrepend();
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -90,21 +90,21 @@  discard block
 block discarded – undo
90 90
     protected function analyzePrepend(string $subject) : void
91 91
     {
92 92
         // we're at the beginning of the string
93
-        if($this->position == 0)
93
+        if ($this->position == 0)
94 94
         {
95 95
             return;
96 96
         }
97 97
         
98 98
         $prevPos = $this->position - $this->eolLength;
99 99
         
100
-        if($prevPos < 0)
100
+        if ($prevPos < 0)
101 101
         {
102 102
             $prevPos = 0;
103 103
         }
104 104
         
105 105
         $prev = mb_substr($subject, $prevPos, $this->eolLength);
106 106
         
107
-        if($prev !== $this->formatter->getEOLChar())
107
+        if ($prev !== $this->formatter->getEOLChar())
108 108
         {
109 109
             $this->prepend = true;
110 110
         }
@@ -117,21 +117,21 @@  discard block
 block discarded – undo
117 117
         $position = $this->position + $this->placeholderLength;
118 118
         
119 119
         // we're at the end of the string
120
-        if($position >= $subjectLength)
120
+        if ($position >= $subjectLength)
121 121
         {
122 122
             return;
123 123
         }
124 124
         
125 125
         $nextPos = $position + $this->eolLength;
126 126
         
127
-        if($nextPos > $subjectLength)
127
+        if ($nextPos > $subjectLength)
128 128
         {
129 129
             $nextPos = $subjectLength - $this->eolLength;
130 130
         }
131 131
         
132 132
         $next = mb_substr($subject, $nextPos, $this->eolLength);
133 133
         
134
-        if($next !== $this->formatter->getEOLChar())
134
+        if ($next !== $this->formatter->getEOLChar())
135 135
         {
136 136
             $this->append = true;
137 137
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/SingleLines.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class Mailcode_Parser_Safeguard_Formatter_SingleLines extends Mailcode_Parser_Safeguard_Formatter
25 25
 {
26
-   /**
27
-    * @var string
28
-    */
26
+    /**
27
+     * @var string
28
+     */
29 29
     protected $eol;
30 30
     
31
-   /**
32
-    * @var int
33
-    */
31
+    /**
32
+     * @var int
33
+     */
34 34
     protected $eolLength;
35 35
     
36 36
     public function format(string $subject) : string
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
         return $prepend.$placeholder.$append;
120 120
     }
121 121
     
122
-   /**
123
-    * We only use placeholders that contain commands that do
124
-    * not generate contents, since these are the only ones
125
-    * that may need adjusting.
126
-    * 
127
-    * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
128
-    */
122
+    /**
123
+     * We only use placeholders that contain commands that do
124
+     * not generate contents, since these are the only ones
125
+     * that may need adjusting.
126
+     * 
127
+     * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
128
+     */
129 129
     protected function filterPlaceholders()
130 130
     {
131 131
         $placeholders = $this->safeguard->getPlaceholders();
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         
43 43
         $total = count($placeholders);
44 44
         
45
-        for($i=0; $i < $total; $i++)
45
+        for ($i = 0; $i < $total; $i++)
46 46
         {
47 47
             $subject = $this->process($placeholders[$i], $subject);
48 48
         }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $phLength = mb_strlen($placeholder);
67 67
         $offset = 0;
68 68
         
69
-        foreach($positions as $position)
69
+        foreach ($positions as $position)
70 70
         {
71 71
             // adjust the position if previous changes made the subject longer
72 72
             $position += $offset;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
                 $position
79 79
             );
80 80
             
81
-            if(!$info->requiresAdjustment())
81
+            if (!$info->requiresAdjustment())
82 82
             {
83 83
                 continue;
84 84
             }
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
         $prepend = '';
107 107
         $append = '';
108 108
         
109
-        if($info->requiresPrepend())
109
+        if ($info->requiresPrepend())
110 110
         {
111 111
             $prepend = $this->eol;
112 112
         }
113 113
         
114
-        if($info->requiresAppend())
114
+        if ($info->requiresAppend())
115 115
         {
116 116
             $append = $this->eol;
117 117
         }
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
         
133 133
         $result = array();
134 134
         
135
-        foreach($placeholders as $placeholder)
135
+        foreach ($placeholders as $placeholder)
136 136
         {
137
-            if(!$placeholder->getCommand()->generatesContent())
137
+            if (!$placeholder->getCommand()->generatesContent())
138 138
             {
139 139
                 $result[] = $placeholder;
140 140
             }
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(isset($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(isset($this->placeholderStrings))
404
+        if (isset($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.