Passed
Push — master ( 75ee28...758f58 )
by Sebastian
04:00
created
src/Mailcode/Parser/Safeguard/Formatter/ReplacerType.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@
 block discarded – undo
35 35
         }
36 36
     }
37 37
     
38
-   /**
39
-    * Resolves the string with which this location needs to be
40
-    * replaced.
41
-    * 
42
-    * @param Mailcode_Parser_Safeguard_Formatter_Location $location
43
-    * @return string
44
-    */
38
+    /**
39
+     * Resolves the string with which this location needs to be
40
+     * replaced.
41
+     * 
42
+     * @param Mailcode_Parser_Safeguard_Formatter_Location $location
43
+     * @return string
44
+     */
45 45
     private function resolveReplacement(Mailcode_Parser_Safeguard_Formatter_Location $location) : string
46 46
     {
47 47
         if($location->requiresAdjustment())
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     {
30 30
         $locations = $this->resolveLocations();
31 31
         
32
-        foreach($locations as $location)
32
+        foreach ($locations as $location)
33 33
         {
34 34
             $location->replaceWith($this->resolveReplacement($location));
35 35
             
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     */
47 47
     private function resolveReplacement(Mailcode_Parser_Safeguard_Formatter_Location $location) : string
48 48
     {
49
-        if($location->requiresAdjustment())
49
+        if ($location->requiresAdjustment())
50 50
         {
51 51
             return $this->getReplaceString($location);
52 52
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/SingleLines.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@
 block discarded – undo
23 23
  */
24 24
 class Mailcode_Parser_Safeguard_Formatter_Type_SingleLines extends Mailcode_Parser_Safeguard_Formatter_FormatType
25 25
 {
26
-   /**
27
-    * @var string
28
-    */
26
+    /**
27
+     * @var string
28
+     */
29 29
     private $eol;
30 30
     
31
-   /**
32
-    * @var int
33
-    */
31
+    /**
32
+     * @var int
33
+     */
34 34
     private $eolLength;
35 35
     
36 36
     protected function initFormatting() : void
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/SingleLines/Location.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@
 block discarded – undo
25 25
  */
26 26
 class Mailcode_Parser_Safeguard_Formatter_Type_SingleLines_Location extends Mailcode_Parser_Safeguard_Formatter_Location
27 27
 {
28
-   /**
29
-    * @var int
30
-    */
28
+    /**
29
+     * @var int
30
+     */
31 31
     protected $eolLength;
32 32
     
33
-   /**
34
-    * @var string
35
-    */
33
+    /**
34
+     * @var string
35
+     */
36 36
     protected $eol;
37 37
     
38 38
     protected function init() : void
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $position = $this->getStartPosition();
56 56
         
57 57
         // we're at the beginning of the string
58
-        if($position === false || $position === 0)
58
+        if ($position === false || $position === 0)
59 59
         {
60 60
             $this->log(sprintf(
61 61
                 'Prepend: NO | Position: [%s] | Not found, or at beginning of string.', 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         
68 68
         $prevPos = $position - $this->eolLength;
69 69
         
70
-        if($prevPos < 0)
70
+        if ($prevPos < 0)
71 71
         {
72 72
             $prevPos = 0;
73 73
         }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     
78 78
     protected function checkPreviousPosition(int $prevPos) : void
79 79
     {
80
-        if($this->isWithinCommand($prevPos))
80
+        if ($this->isWithinCommand($prevPos))
81 81
         {
82 82
             $this->log(sprintf(
83 83
                 'Prepend: NO | Position: [%s] | Is within a mailcode command.', 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         
90 90
         $match = $this->subject->getSubstr($prevPos, $this->eolLength);
91 91
         
92
-        if($match !== $this->formatter->getEOLChar())
92
+        if ($match !== $this->formatter->getEOLChar())
93 93
         {
94 94
             $this->log(sprintf(
95 95
                 'Prepend: YES | Position: [%s] | Characters: [%s] | Do not match the EOL character.',
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         $position = $this->getEndPosition();
109 109
         
110 110
         // we're at the end of the string
111
-        if($position === false || $position >= $subjectLength)
111
+        if ($position === false || $position >= $subjectLength)
112 112
         {
113 113
             $this->log(sprintf(
114 114
                 'Append: NO | Position: [%s] | End of string, or too long | Subject length: [%s]',
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         
122 122
         $nextPos = $position + $this->eolLength;
123 123
         
124
-        if($nextPos > $subjectLength)
124
+        if ($nextPos > $subjectLength)
125 125
         {
126 126
             $nextPos = $subjectLength - $this->eolLength;
127 127
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     
132 132
     protected function checkNextPosition(int $nextPos) : void
133 133
     {
134
-        if($this->isWithinCommand($nextPos))
134
+        if ($this->isWithinCommand($nextPos))
135 135
         {
136 136
             $this->log(sprintf(
137 137
                 'Append: YES | Position: [%s] | Is within a mailcode command.',
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         
146 146
         $next = $this->subject->getSubstr($nextPos, $this->eolLength);
147 147
         
148
-        if($next !== $this->formatter->getEOLChar())
148
+        if ($next !== $this->formatter->getEOLChar())
149 149
         {
150 150
             $this->log(sprintf(
151 151
                 'Append: YES | Position: [%s] | Next characters: [%s] | Do not match the EOL character.',
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/MarkVariables/Location.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
     
33 33
     public function requiresAdjustment(): bool
34 34
     {
35
-        if(!parent::requiresAdjustment())
35
+        if (!parent::requiresAdjustment())
36 36
         {
37 37
             return false;
38 38
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/HTMLHighlighting/Location.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,8 +119,7 @@
 block discarded – undo
119 119
             if($closing)
120 120
             {
121 121
                 array_pop($stack);
122
-            }
123
-            else
122
+            } else
124 123
             {
125 124
                 $stack[] = $tagName;
126 125
             }
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
 {
25 25
     const COMMAND_MARKER = '__MAILCODE_COMMAND__';
26 26
     
27
-   /**
28
-    * @var boolean
29
-    */
27
+    /**
28
+     * @var boolean
29
+     */
30 30
     private $ancestryChecked = false;
31 31
     
32
-   /**
33
-    * @var array<int,array<int,string>>
34
-    */
32
+    /**
33
+     * @var array<int,array<int,string>>
34
+     */
35 35
     private $tagAncestry = array();
36 36
     
37 37
     protected function init() : void
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
         return !$this->isInTagAttributes() && !$this->isInExcludedTag();
44 44
     }
45 45
     
46
-   /**
47
-    * Retrieves the part of the subject string that comes
48
-    * before the command.
49
-    * 
50
-    * @return string
51
-    */
46
+    /**
47
+     * Retrieves the part of the subject string that comes
48
+     * before the command.
49
+     * 
50
+     * @return string
51
+     */
52 52
     private function getHaystackBefore() : string
53 53
     {
54 54
         $pos = $this->getStartPosition();
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
         return $this->subject->getSubstr(0, $pos).self::COMMAND_MARKER.'>';
66 66
     }
67 67
     
68
-   /**
69
-    * Whether the command is nested in one of the tags
70
-    * that have been added to the list of excluded tags.
71
-    * 
72
-    * @return bool
73
-    */
68
+    /**
69
+     * Whether the command is nested in one of the tags
70
+     * that have been added to the list of excluded tags.
71
+     * 
72
+     * @return bool
73
+     */
74 74
     protected function isInExcludedTag() : bool
75 75
     {
76 76
         $tagNames = $this->getParentTags();
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
         return false;
87 87
     }
88 88
     
89
-   /**
90
-    * Retrieves a list of the command's parent HTML tags, from
91
-    * highest to lowest.
92
-    * 
93
-    * @return string[]
94
-    */
89
+    /**
90
+     * Retrieves a list of the command's parent HTML tags, from
91
+     * highest to lowest.
92
+     * 
93
+     * @return string[]
94
+     */
95 95
     private function getParentTags() : array
96 96
     {
97 97
         $tags = $this->getTagAncestry();
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
         return $stack;
117 117
     }
118 118
     
119
-   /**
120
-    * Checks whether the command is located within the attributes
121
-    * of an HTML tag.
122
-    * 
123
-    * @return bool
124
-    */
119
+    /**
120
+     * Checks whether the command is located within the attributes
121
+     * of an HTML tag.
122
+     * 
123
+     * @return bool
124
+     */
125 125
     protected function isInTagAttributes() : bool
126 126
     {
127 127
         $tags = $this->getTagAncestry();
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
         return false;
140 140
     }
141 141
     
142
-   /**
143
-    * Retrieves a list of tag names that come as parents 
144
-    * above the command.
145
-    * 
146
-    * @return array<int,array<int,string>>
147
-    */
142
+    /**
143
+     * Retrieves a list of tag names that come as parents 
144
+     * above the command.
145
+     * 
146
+     * @return array<int,array<int,string>>
147
+     */
148 148
     private function getTagAncestry() : array
149 149
     {
150 150
         if($this->ancestryChecked)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     {
54 54
         $pos = $this->getStartPosition();
55 55
         
56
-        if(is_bool($pos))
56
+        if (is_bool($pos))
57 57
         {
58 58
             return '';
59 59
         }
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
     {
76 76
         $tagNames = $this->getParentTags();
77 77
         
78
-        foreach($tagNames as $tagName)
78
+        foreach ($tagNames as $tagName)
79 79
         {
80
-            if($this->formatter->isTagExcluded($tagName))
80
+            if ($this->formatter->isTagExcluded($tagName))
81 81
             {
82 82
                 return true;
83 83
             }
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
         // Create a stack of all direct parent tags of the command.
100 100
         // Handles closing tags as well.
101 101
         $stack = array();
102
-        foreach($tags[2] as $idx => $tagName)
102
+        foreach ($tags[2] as $idx => $tagName)
103 103
         {
104 104
             $closing = $tags[1][$idx] === '/';
105 105
             
106
-            if($closing)
106
+            if ($closing)
107 107
             {
108 108
                 array_pop($stack);
109 109
             }
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
         
129 129
         // This check is easy: if the command is in the attribute
130 130
         // of any of the tags, we will find the command marker in there.
131
-        foreach($tags[3] as $attributes)
131
+        foreach ($tags[3] as $attributes)
132 132
         {
133
-            if(strstr($attributes, self::COMMAND_MARKER))
133
+            if (strstr($attributes, self::COMMAND_MARKER))
134 134
             {
135 135
                 return true;
136 136
             }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     */
148 148
     private function getTagAncestry() : array
149 149
     {
150
-        if($this->ancestryChecked)
150
+        if ($this->ancestryChecked)
151 151
         {
152 152
             return $this->tagAncestry;
153 153
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/FormatType.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@
 block discarded – undo
25 25
         return PHP_INT_MAX;
26 26
     }
27 27
 
28
-   /**
29
-    * Formats the specified string according to the formatter.
30
-    * Retrieve the updated string from the string container used
31
-    * to create the formatter, or use `getSubjectString()`.
32
-    */
28
+    /**
29
+     * Formats the specified string according to the formatter.
30
+     * Retrieve the updated string from the string container used
31
+     * to create the formatter, or use `getSubjectString()`.
32
+     */
33 33
     public function format() : void
34 34
     {
35 35
         $locations = $this->resolveLocations();
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
     {
35 35
         $locations = $this->resolveLocations();
36 36
         
37
-        foreach($locations as $location)
37
+        foreach ($locations as $location)
38 38
         {
39 39
             $location->format();
40 40
             
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatting.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     
132 132
     public function applyFormatting() : void
133 133
     {
134
-        if($this->applied)
134
+        if ($this->applied)
135 135
         {
136 136
             return;
137 137
         }
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
 
147 147
     private function applyFormatTypes() : void
148 148
     {
149
-        foreach($this->formatters as $formatter)
149
+        foreach ($this->formatters as $formatter)
150 150
         {
151
-            if($formatter instanceof Mailcode_Parser_Safeguard_Formatter_FormatType)
151
+            if ($formatter instanceof Mailcode_Parser_Safeguard_Formatter_FormatType)
152 152
             {
153 153
                 $formatter->format();
154 154
             }
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
     
158 158
     private function applyReplaceTypes() : void
159 159
     {
160
-        foreach($this->formatters as $formatter)
160
+        foreach ($this->formatters as $formatter)
161 161
         {
162
-            if($formatter instanceof Mailcode_Parser_Safeguard_Formatter_ReplacerType)
162
+            if ($formatter instanceof Mailcode_Parser_Safeguard_Formatter_ReplacerType)
163 163
             {
164 164
                 $formatter->replace();
165 165
             }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     
169 169
     private function validateFormatters() : void
170 170
     {
171
-        if(empty($this->formatters))
171
+        if (empty($this->formatters))
172 172
         {
173 173
             throw new Mailcode_Exception(
174 174
                 'No formatters selected',
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         
180 180
         $amount = $this->countReplacers();
181 181
         
182
-        if($amount > 1) 
182
+        if ($amount > 1) 
183 183
         {
184 184
             throw new Mailcode_Exception(
185 185
                 'More than one replacer formatter selected',
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
         }
190 190
         
191 191
         // by default, at minimum the normalized formatter must be selected.
192
-        if($amount === 0)
192
+        if ($amount === 0)
193 193
         {
194 194
             $this->replaceWithNormalized();
195 195
         }
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
     {
205 205
         $count = 0;
206 206
         
207
-        foreach($this->formatters as $formatter)
207
+        foreach ($this->formatters as $formatter)
208 208
         {
209
-            if($formatter instanceof Mailcode_Parser_Safeguard_Formatter_ReplacerType)
209
+            if ($formatter instanceof Mailcode_Parser_Safeguard_Formatter_ReplacerType)
210 210
             {
211 211
                 $count++;
212 212
             }
Please login to merge, or discard this patch.
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -32,29 +32,29 @@  discard block
 block discarded – undo
32 32
     const ERROR_TOO_MANY_REPLACERS = 65902;
33 33
     const ERROR_NO_FORMATTERS_ADDED = 65903;
34 34
     
35
-   /**
36
-    * @var Mailcode_Parser_Safeguard
37
-    */
35
+    /**
36
+     * @var Mailcode_Parser_Safeguard
37
+     */
38 38
     private $safeguard;
39 39
     
40
-   /**
41
-    * @var Mailcode_Parser_Safeguard_Formatter[]
42
-    */
40
+    /**
41
+     * @var Mailcode_Parser_Safeguard_Formatter[]
42
+     */
43 43
     private $formatters = array();
44 44
     
45
-   /**
46
-    * @var Mailcode_StringContainer
47
-    */
45
+    /**
46
+     * @var Mailcode_StringContainer
47
+     */
48 48
     private $subject;
49 49
     
50
-   /**
51
-    * @var boolean
52
-    */
50
+    /**
51
+     * @var boolean
52
+     */
53 53
     private $applied = false;
54 54
     
55
-   /**
56
-    * @var boolean
57
-    */
55
+    /**
56
+     * @var boolean
57
+     */
58 58
     private $partial = false;
59 59
     
60 60
     public function __construct(Mailcode_Parser_Safeguard $safeguard, Mailcode_StringContainer $subject)
@@ -96,17 +96,17 @@  discard block
 block discarded – undo
96 96
         return $formatter;
97 97
     }
98 98
     
99
-   /**
100
-    * Adds a formatter that will surround all variables with
101
-    * markup to highlight them independently of command syntax
102
-    * highlighting.
103
-    * 
104
-    * This is used to mark variables visually even after commands
105
-    * have been replaced by the target system's post processing.
106
-    * Can be combined with a replacer and other formats.
107
-    * 
108
-    * @return Mailcode_Parser_Safeguard_Formatter_Type_MarkVariables
109
-    */
99
+    /**
100
+     * Adds a formatter that will surround all variables with
101
+     * markup to highlight them independently of command syntax
102
+     * highlighting.
103
+     * 
104
+     * This is used to mark variables visually even after commands
105
+     * have been replaced by the target system's post processing.
106
+     * Can be combined with a replacer and other formats.
107
+     * 
108
+     * @return Mailcode_Parser_Safeguard_Formatter_Type_MarkVariables
109
+     */
110 110
     public function formatWithMarkedVariables() : Mailcode_Parser_Safeguard_Formatter_Type_MarkVariables
111 111
     {
112 112
         $formatter = $this->createMarkVariables();
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
         }
201 201
     }
202 202
     
203
-   /**
204
-    * Counts the amount of replacer formatters that have been added.
205
-    * 
206
-    * @return int
207
-    */
203
+    /**
204
+     * Counts the amount of replacer formatters that have been added.
205
+     * 
206
+     * @return int
207
+     */
208 208
     private function countReplacers() : int
209 209
     {
210 210
         $count = 0;
@@ -220,37 +220,37 @@  discard block
 block discarded – undo
220 220
         return $count;
221 221
     }
222 222
 
223
-   /**
224
-    * Creates a formatter that adds HTML syntax highlighting
225
-    * for all commands in the specified string, intelligently
226
-    * checking the location of the commands to ensure that they
227
-    * can be syntax highlighted.
228
-    * 
229
-    * For example, commands in HTML attributes will not be
230
-    * highlighted, as this would break the HTML.
231
-    *  
232
-    * @return Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting
233
-    */
223
+    /**
224
+     * Creates a formatter that adds HTML syntax highlighting
225
+     * for all commands in the specified string, intelligently
226
+     * checking the location of the commands to ensure that they
227
+     * can be syntax highlighted.
228
+     * 
229
+     * For example, commands in HTML attributes will not be
230
+     * highlighted, as this would break the HTML.
231
+     *  
232
+     * @return Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting
233
+     */
234 234
     public function createHTMLHighlighting() : Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting
235 235
     {
236 236
         return new Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting($this);
237 237
     }
238 238
 
239
-   /**
240
-    * Creates the formatter that ensures that all commands
241
-    * are placed on a separate line in the subject string.
242
-    */
239
+    /**
240
+     * Creates the formatter that ensures that all commands
241
+     * are placed on a separate line in the subject string.
242
+     */
243 243
     public function createSingleLines() : Mailcode_Parser_Safeguard_Formatter_Type_SingleLines
244 244
     {
245 245
         return new Mailcode_Parser_Safeguard_Formatter_Type_SingleLines($this);
246 246
     }
247 247
     
248
-   /**
249
-    * Creates the formatter that replaces all commands by
250
-    * their normalized variants.
251
-    * 
252
-    * @return Mailcode_Parser_Safeguard_Formatter_Type_Normalized
253
-    */
248
+    /**
249
+     * Creates the formatter that replaces all commands by
250
+     * their normalized variants.
251
+     * 
252
+     * @return Mailcode_Parser_Safeguard_Formatter_Type_Normalized
253
+     */
254 254
     public function createNormalized() : Mailcode_Parser_Safeguard_Formatter_Type_Normalized
255 255
     {
256 256
         return new Mailcode_Parser_Safeguard_Formatter_Type_Normalized($this);
@@ -273,26 +273,26 @@  discard block
 block discarded – undo
273 273
         return $this->subject->getString();
274 274
     }
275 275
 
276
-   /**
277
-    * Whether the formatting is done partially: missing placeholders
278
-    * will simply be ignored.
279
-    * 
280
-    * @return bool
281
-    */
276
+    /**
277
+     * Whether the formatting is done partially: missing placeholders
278
+     * will simply be ignored.
279
+     * 
280
+     * @return bool
281
+     */
282 282
     public function isPartial() : bool
283 283
     {
284 284
         return $this->partial;
285 285
     }
286 286
     
287
-   /**
288
-    * The formatting will ignore missing placeholders. Use this if the
289
-    * formatting will be done on a text that may not contain all of the
290
-    * initial placeholders anymore.
291
-    * 
292
-    * This is like the safeguard's makeWholePartial() method.
293
-    * 
294
-    * @return Mailcode_Parser_Safeguard_Formatting
295
-    */
287
+    /**
288
+     * The formatting will ignore missing placeholders. Use this if the
289
+     * formatting will be done on a text that may not contain all of the
290
+     * initial placeholders anymore.
291
+     * 
292
+     * This is like the safeguard's makeWholePartial() method.
293
+     * 
294
+     * @return Mailcode_Parser_Safeguard_Formatting
295
+     */
296 296
     public function makePartial() : Mailcode_Parser_Safeguard_Formatting
297 297
     {
298 298
         $this->partial = true;
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -260,8 +260,7 @@
 block discarded – undo
260 260
         if($highlighted)
261 261
         {
262 262
             $formatting->replaceWithHTMLHighlighting();
263
-        }
264
-        else 
263
+        } else 
265 264
         {
266 265
             $formatting->replaceWithNormalized();
267 266
         }
Please login to merge, or discard this patch.
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -55,50 +55,50 @@  discard block
 block discarded – undo
55 55
     const ERROR_EMPTY_DELIMITER = 47803;
56 56
     const ERROR_PLACEHOLDER_NOT_FOUND = 47804;
57 57
     
58
-   /**
59
-    * @var Mailcode_Parser
60
-    */
58
+    /**
59
+     * @var Mailcode_Parser
60
+     */
61 61
     protected $parser;
62 62
     
63
-   /**
64
-    * @var Mailcode_Collection
65
-    */
63
+    /**
64
+     * @var Mailcode_Collection
65
+     */
66 66
     protected $commands;
67 67
     
68
-   /**
69
-    * @var string
70
-    */
68
+    /**
69
+     * @var string
70
+     */
71 71
     protected $originalString;
72 72
     
73
-   /**
74
-    * @var Mailcode_Collection
75
-    */
73
+    /**
74
+     * @var Mailcode_Collection
75
+     */
76 76
     protected $collection;
77 77
     
78
-   /**
79
-    * Counter for the placeholders, global for all placeholders.
80
-    * @var integer
81
-    */
78
+    /**
79
+     * Counter for the placeholders, global for all placeholders.
80
+     * @var integer
81
+     */
82 82
     private static $counter = 0;
83 83
     
84
-   /**
85
-    * @var Mailcode_Parser_Safeguard_Placeholder[]
86
-    */
84
+    /**
85
+     * @var Mailcode_Parser_Safeguard_Placeholder[]
86
+     */
87 87
     protected $placeholders;
88 88
     
89
-   /**
90
-    * @var string
91
-    */
89
+    /**
90
+     * @var string
91
+     */
92 92
     protected $delimiter = '__';
93 93
     
94
-   /**
95
-    * @var string[]|NULL
96
-    */
94
+    /**
95
+     * @var string[]|NULL
96
+     */
97 97
     protected $placeholderStrings;
98 98
     
99
-   /**
100
-    * @var Mailcode_Parser_Safeguard_Formatting|NULL
101
-    */
99
+    /**
100
+     * @var Mailcode_Parser_Safeguard_Formatting|NULL
101
+     */
102 102
     private $formatting = null;
103 103
     
104 104
     public function __construct(Mailcode_Parser $parser, string $subject)
@@ -107,25 +107,25 @@  discard block
 block discarded – undo
107 107
         $this->originalString = $subject;
108 108
     }
109 109
     
110
-   /**
111
-    * Retrieves the string the safeguard was created for.
112
-    * 
113
-    * @return string
114
-    */
110
+    /**
111
+     * Retrieves the string the safeguard was created for.
112
+     * 
113
+     * @return string
114
+     */
115 115
     public function getOriginalString() : string
116 116
     {
117 117
         return $this->originalString;
118 118
     }
119 119
     
120
-   /**
121
-    * Sets the delimiter character sequence used to prepend
122
-    * and append to the placeholders.
123
-    * 
124
-    * The delimiter's default is "__" (two underscores).
125
-    * 
126
-    * @param string $delimiter
127
-    * @return Mailcode_Parser_Safeguard
128
-    */
120
+    /**
121
+     * Sets the delimiter character sequence used to prepend
122
+     * and append to the placeholders.
123
+     * 
124
+     * The delimiter's default is "__" (two underscores).
125
+     * 
126
+     * @param string $delimiter
127
+     * @return Mailcode_Parser_Safeguard
128
+     */
129 129
     public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard
130 130
     {
131 131
         if(empty($delimiter))
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
         return $this->delimiter;
148 148
     }
149 149
     
150
-   /**
151
-    * Retrieves the safe string in which all commands have been replaced
152
-    * by placeholder strings.
153
-    *
154
-    * @return string
155
-    * @throws Mailcode_Exception 
156
-    *
157
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
158
-    */
150
+    /**
151
+     * Retrieves the safe string in which all commands have been replaced
152
+     * by placeholder strings.
153
+     *
154
+     * @return string
155
+     * @throws Mailcode_Exception 
156
+     *
157
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
158
+     */
159 159
     public function makeSafe() : string
160 160
     {
161 161
         $this->requireValidCollection();
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
         return $this->makeSafePartial();
164 164
     }
165 165
     
166
-   /**
167
-    * Like makeSafe(), but allows partial (invalid) commands: use this
168
-    * if the subject string may contain only part of the whole set of
169
-    * commands. 
170
-    * 
171
-    * Example: parsing a text with an opening if statement, without the 
172
-    * matching end statement.
173
-    * 
174
-    * @return string
175
-    */
166
+    /**
167
+     * Like makeSafe(), but allows partial (invalid) commands: use this
168
+     * if the subject string may contain only part of the whole set of
169
+     * commands. 
170
+     * 
171
+     * Example: parsing a text with an opening if statement, without the 
172
+     * matching end statement.
173
+     * 
174
+     * @return string
175
+     */
176 176
     public function makeSafePartial() : string
177 177
     {
178 178
         $placeholders = $this->getPlaceholders();
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
         }
241 241
     }
242 242
     
243
-   /**
244
-    * Creates a formatting handler, which can be used to specify
245
-    * which formattings to use for the commands in the subject string.
246
-    * 
247
-    * @param Mailcode_StringContainer|string $subject
248
-    * @return Mailcode_Parser_Safeguard_Formatting
249
-    */
243
+    /**
244
+     * Creates a formatting handler, which can be used to specify
245
+     * which formattings to use for the commands in the subject string.
246
+     * 
247
+     * @param Mailcode_StringContainer|string $subject
248
+     * @return Mailcode_Parser_Safeguard_Formatting
249
+     */
250 250
     public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting
251 251
     {
252 252
         if(is_string($subject))
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
         return new Mailcode_Parser_Safeguard_Formatting($this, $subject);
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,16 +314,16 @@  discard block
 block discarded – undo
314 314
         return $formatting->toString();
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
-    */
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
+     */
327 327
     public function makeWhole(string $string) : string
328 328
     {
329 329
         return $this->restore(
@@ -333,15 +333,15 @@  discard block
 block discarded – undo
333 333
         );
334 334
     }
335 335
     
336
-   /**
337
-    * Like `makeWhole()`, but ignores missing command placeholders.
338
-    *
339
-    * @param string $string
340
-    * @return string
341
-    * @throws Mailcode_Exception
342
-    *
343
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
344
-    */
336
+    /**
337
+     * Like `makeWhole()`, but ignores missing command placeholders.
338
+     *
339
+     * @param string $string
340
+     * @return string
341
+     * @throws Mailcode_Exception
342
+     *
343
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
344
+     */
345 345
     public function makeWholePartial(string $string) : string
346 346
     {
347 347
         return $this->restore(
@@ -351,19 +351,19 @@  discard block
 block discarded – undo
351 351
         );
352 352
     }
353 353
 
354
-   /**
355
-    * Like `makeWhole()`, but replaces the commands with a syntax
356
-    * highlighted version, meant for human readable texts only.
357
-    * 
358
-    * Note: the commands lose their functionality (They cannot be 
359
-    * parsed from that string again).
360
-    *
361
-    * @param string $string
362
-    * @return string
363
-    * @throws Mailcode_Exception
364
-    *
365
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
366
-    */
354
+    /**
355
+     * Like `makeWhole()`, but replaces the commands with a syntax
356
+     * highlighted version, meant for human readable texts only.
357
+     * 
358
+     * Note: the commands lose their functionality (They cannot be 
359
+     * parsed from that string again).
360
+     *
361
+     * @param string $string
362
+     * @return string
363
+     * @throws Mailcode_Exception
364
+     *
365
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
366
+     */
367 367
     public function makeHighlighted(string $string) : string
368 368
     {
369 369
         return $this->restore(
@@ -373,15 +373,15 @@  discard block
 block discarded – undo
373 373
         );
374 374
     }
375 375
     
376
-   /**
377
-    * Like `makeHighlighted()`, but ignores missing command placeholders.
378
-    * 
379
-    * @param string $string
380
-    * @return string
381
-    * @throws Mailcode_Exception
382
-    *
383
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
384
-    */
376
+    /**
377
+     * Like `makeHighlighted()`, but ignores missing command placeholders.
378
+     * 
379
+     * @param string $string
380
+     * @return string
381
+     * @throws Mailcode_Exception
382
+     *
383
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
384
+     */
385 385
     public function makeHighlightedPartial(string $string) : string
386 386
     {
387 387
         return $this->restore(
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
         );
392 392
     }
393 393
     
394
-   /**
395
-    * Retrieves the commands collection contained in the string.
396
-    * 
397
-    * @return Mailcode_Collection
398
-    */
394
+    /**
395
+     * Retrieves the commands collection contained in the string.
396
+     * 
397
+     * @return Mailcode_Collection
398
+     */
399 399
     public function getCollection() : Mailcode_Collection
400 400
     {
401 401
         if(isset($this->collection))
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
         return $this->getCollection()->isValid();
414 414
     }
415 415
     
416
-   /**
417
-    * @throws Mailcode_Exception
418
-    * 
419
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
420
-    */
416
+    /**
417
+     * @throws Mailcode_Exception
418
+     * 
419
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
420
+     */
421 421
     protected function requireValidCollection() : void
422 422
     {
423 423
         if($this->getCollection()->isValid())
@@ -436,11 +436,11 @@  discard block
 block discarded – undo
436 436
         );
437 437
     }
438 438
     
439
-   /**
440
-    * Retrieves a list of all placeholder IDs used in the text.
441
-    * 
442
-    * @return string[]
443
-    */
439
+    /**
440
+     * Retrieves a list of all placeholder IDs used in the text.
441
+     * 
442
+     * @return string[]
443
+     */
444 444
     public function getPlaceholderStrings() : array
445 445
     {
446 446
         if(is_array($this->placeholderStrings))
@@ -467,13 +467,13 @@  discard block
 block discarded – undo
467 467
         return in_array($subject, $ids);
468 468
     }
469 469
     
470
-   /**
471
-    * Retrieves a placeholder instance by its ID.
472
-    * 
473
-    * @param int $id
474
-    * @throws Mailcode_Exception If the placeholder was not found.
475
-    * @return Mailcode_Parser_Safeguard_Placeholder
476
-    */
470
+    /**
471
+     * Retrieves a placeholder instance by its ID.
472
+     * 
473
+     * @param int $id
474
+     * @throws Mailcode_Exception If the placeholder was not found.
475
+     * @return Mailcode_Parser_Safeguard_Placeholder
476
+     */
477 477
     public function getPlaceholderByID(int $id) : Mailcode_Parser_Safeguard_Placeholder
478 478
     {
479 479
         $placeholders = $this->getPlaceholders();
@@ -496,13 +496,13 @@  discard block
 block discarded – undo
496 496
         );
497 497
     }
498 498
     
499
-   /**
500
-    * Retrieves a placeholder instance by its replacement text.
501
-    * 
502
-    * @param string $string
503
-    * @throws Mailcode_Exception
504
-    * @return Mailcode_Parser_Safeguard_Placeholder
505
-    */
499
+    /**
500
+     * Retrieves a placeholder instance by its replacement text.
501
+     * 
502
+     * @param string $string
503
+     * @throws Mailcode_Exception
504
+     * @return Mailcode_Parser_Safeguard_Placeholder
505
+     */
506 506
     public function getPlaceholderByString(string $string) : Mailcode_Parser_Safeguard_Placeholder
507 507
     {
508 508
         $placeholders = $this->getPlaceholders();
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     */
129 129
     public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard
130 130
     {
131
-        if(empty($delimiter))
131
+        if (empty($delimiter))
132 132
         {
133 133
             throw new Mailcode_Exception(
134 134
                 'Empty delimiter',
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         $placeholders = $this->getPlaceholders();
179 179
         $string = $this->originalString;
180 180
         
181
-        foreach($placeholders as $placeholder)
181
+        foreach ($placeholders as $placeholder)
182 182
         {
183 183
             $string = $this->makePlaceholderSafe($string, $placeholder);
184 184
         }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     {
193 193
         $pos = mb_strpos($string, $placeholder->getOriginalText());
194 194
 
195
-        if($pos === false)
195
+        if ($pos === false)
196 196
         {
197 197
             throw new Mailcode_Exception(
198 198
                 'Placeholder original text not found',
@@ -221,18 +221,18 @@  discard block
 block discarded – undo
221 221
         $urls = ConvertHelper::createURLFinder($string)->getURLs();
222 222
         $placeholders = $this->getPlaceholders();
223 223
 
224
-        foreach($urls as $url)
224
+        foreach ($urls as $url)
225 225
         {
226
-            foreach($placeholders as $placeholder)
226
+            foreach ($placeholders as $placeholder)
227 227
             {
228 228
                 $command = $placeholder->getCommand();
229 229
 
230
-                if(!$command->supportsURLEncoding())
230
+                if (!$command->supportsURLEncoding())
231 231
                 {
232 232
                     continue;
233 233
                 }
234 234
 
235
-                if(strstr($url, $placeholder->getReplacementText()))
235
+                if (strstr($url, $placeholder->getReplacementText()))
236 236
                 {
237 237
                     $command->setURLEncoding(true);
238 238
                 }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     */
250 250
     public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting
251 251
     {
252
-        if(is_string($subject))
252
+        if (is_string($subject))
253 253
         {
254 254
             $subject = Mailcode::create()->createString($subject);
255 255
         }
@@ -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()->getCommands();
276 276
         
277
-        foreach($cmds as $command)
277
+        foreach ($cmds as $command)
278 278
         {
279 279
             self::$counter++;
280 280
             
@@ -288,21 +288,21 @@  discard block
 block discarded – undo
288 288
         return $this->placeholders;
289 289
     }
290 290
     
291
-    protected function restore(string $string, bool $partial=false, bool $highlighted=false) : string
291
+    protected function restore(string $string, bool $partial = false, bool $highlighted = false) : string
292 292
     {
293
-        if(!$partial)
293
+        if (!$partial)
294 294
         {
295 295
             $this->requireValidCollection();
296 296
         }
297 297
         
298 298
         $formatting = $this->createFormatting($string);
299 299
 
300
-        if($partial)
300
+        if ($partial)
301 301
         {
302 302
             $formatting->makePartial();
303 303
         }
304 304
         
305
-        if($highlighted)
305
+        if ($highlighted)
306 306
         {
307 307
             $formatting->replaceWithHTMLHighlighting();
308 308
         }
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
     */
399 399
     public function getCollection() : Mailcode_Collection
400 400
     {
401
-        if(isset($this->collection))
401
+        if (isset($this->collection))
402 402
         {
403 403
             return $this->collection;
404 404
         }
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     */
421 421
     protected function requireValidCollection() : void
422 422
     {
423
-        if($this->getCollection()->isValid())
423
+        if ($this->getCollection()->isValid())
424 424
         {
425 425
             return;
426 426
         }
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
     */
444 444
     public function getPlaceholderStrings() : array
445 445
     {
446
-        if(is_array($this->placeholderStrings))
446
+        if (is_array($this->placeholderStrings))
447 447
         {
448 448
             return $this->placeholderStrings;
449 449
         }
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
         
453 453
         $this->placeholderStrings = array();
454 454
         
455
-        foreach($placeholders as $placeholder)
455
+        foreach ($placeholders as $placeholder)
456 456
         {
457 457
             $this->placeholderStrings[] = $placeholder->getReplacementText();
458 458
         }
@@ -478,9 +478,9 @@  discard block
 block discarded – undo
478 478
     {
479 479
         $placeholders = $this->getPlaceholders();
480 480
         
481
-        foreach($placeholders as $placeholder)
481
+        foreach ($placeholders as $placeholder)
482 482
         {
483
-            if($placeholder->getID() === $id)
483
+            if ($placeholder->getID() === $id)
484 484
             {
485 485
                 return $placeholder;
486 486
             }
@@ -507,9 +507,9 @@  discard block
 block discarded – undo
507 507
     {
508 508
         $placeholders = $this->getPlaceholders();
509 509
         
510
-        foreach($placeholders as $placeholder)
510
+        foreach ($placeholders as $placeholder)
511 511
         {
512
-            if($placeholder->getReplacementText() === $string)
512
+            if ($placeholder->getReplacementText() === $string)
513 513
             {
514 514
                 return $placeholder;
515 515
             }
Please login to merge, or discard this patch.
src/Mailcode/StringContainer.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -26,39 +26,39 @@  discard block
 block discarded – undo
26 26
     const ERROR_INVALID_CALLABLE = 65701;
27 27
     const ERROR_UPDATE_CALLED_DURING_UPDATE_OPERATION = 65702;
28 28
     
29
-   /**
30
-    * @var string
31
-    */
29
+    /**
30
+     * @var string
31
+     */
32 32
     private $subject;
33 33
     
34
-   /**
35
-    * @var integer
36
-    */
34
+    /**
35
+     * @var integer
36
+     */
37 37
     private static $listenerCounter = 0;
38 38
     
39
-   /**
40
-    * @var callable[]
41
-    */
39
+    /**
40
+     * @var callable[]
41
+     */
42 42
     private $listeners = array();
43 43
     
44
-   /**
45
-    * @var boolean
46
-    */
44
+    /**
45
+     * @var boolean
46
+     */
47 47
     private $updating = false;
48 48
     
49
-   /**
50
-    * @var integer
51
-    */
49
+    /**
50
+     * @var integer
51
+     */
52 52
     private static $idCounter = 0;
53 53
     
54
-   /**
55
-    * @var integer
56
-    */
54
+    /**
55
+     * @var integer
56
+     */
57 57
     private $id;
58 58
     
59
-   /**
60
-    * @var integer
61
-    */
59
+    /**
60
+     * @var integer
61
+     */
62 62
     private $length;
63 63
     
64 64
     public function __construct(string $subject)
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
         return $this->id;
76 76
     }
77 77
     
78
-   /**
79
-    * Updates the string with the specified string.
80
-    * Notifies all listeners of the change.
81
-    * 
82
-    * @param string $subject
83
-    * @throws Mailcode_Exception
84
-    * @return bool Whether the string had modifications.
85
-    * 
86
-    * @see Mailcode_StringContainer::ERROR_UPDATE_CALLED_DURING_UPDATE_OPERATION
87
-    */
78
+    /**
79
+     * Updates the string with the specified string.
80
+     * Notifies all listeners of the change.
81
+     * 
82
+     * @param string $subject
83
+     * @throws Mailcode_Exception
84
+     * @return bool Whether the string had modifications.
85
+     * 
86
+     * @see Mailcode_StringContainer::ERROR_UPDATE_CALLED_DURING_UPDATE_OPERATION
87
+     */
88 88
     public function updateString(string $subject) : bool
89 89
     {
90 90
         // avoid triggering an update if there are no changes in the string
@@ -117,27 +117,27 @@  discard block
 block discarded – undo
117 117
         return true;
118 118
     }
119 119
     
120
-   /**
121
-    * Retrieves the stored string.
122
-    * 
123
-    * @return string
124
-    */
120
+    /**
121
+     * Retrieves the stored string.
122
+     * 
123
+     * @return string
124
+     */
125 125
     public function getString() : string
126 126
     {
127 127
         return $this->subject;
128 128
     }
129 129
     
130
-   /**
131
-    * Adds a listener that will be informed every time the string is modified.
132
-    * The callback gets the string container instance as parameter.
133
-    * 
134
-    * @param callable $callback
135
-    * @throws Mailcode_Exception If it is not a valid callable.
136
-    * @return int The listener number, to be able to remove it using `removeListener()`.
137
-    * 
138
-    * @see Mailcode_StringContainer::removeListener()
139
-    * @see Mailcode_StringContainer::ERROR_INVALID_CALLABLE
140
-    */
130
+    /**
131
+     * Adds a listener that will be informed every time the string is modified.
132
+     * The callback gets the string container instance as parameter.
133
+     * 
134
+     * @param callable $callback
135
+     * @throws Mailcode_Exception If it is not a valid callable.
136
+     * @return int The listener number, to be able to remove it using `removeListener()`.
137
+     * 
138
+     * @see Mailcode_StringContainer::removeListener()
139
+     * @see Mailcode_StringContainer::ERROR_INVALID_CALLABLE
140
+     */
141 141
     public function addListener($callback) : int
142 142
     {
143 143
         self::$listenerCounter++;
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
         return $this->length;
165 165
     }
166 166
     
167
-   /**
168
-    * Removes an existing listener by its ID.
169
-    * Has no effect if it does not exist, or has already been removed.
170
-    * 
171
-    * @param int $listenerID
172
-    */
167
+    /**
168
+     * Removes an existing listener by its ID.
169
+     * Has no effect if it does not exist, or has already been removed.
170
+     * 
171
+     * @param int $listenerID
172
+     */
173 173
     public function removeListener(int $listenerID) : void
174 174
     {
175 175
         if(isset($this->listeners[$listenerID]))
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
         }
179 179
     }
180 180
     
181
-   /**
182
-    * Replaces all substrings matching needle with the replacement text.
183
-    *  
184
-    * @param string $needle
185
-    * @param string $replacement
186
-    * @return bool
187
-    */
181
+    /**
182
+     * Replaces all substrings matching needle with the replacement text.
183
+     *  
184
+     * @param string $needle
185
+     * @param string $replacement
186
+     * @return bool
187
+     */
188 188
     public function replaceSubstrings(string $needle, string $replacement) : bool
189 189
     {
190 190
         $string = str_replace($needle, $replacement, $this->subject);
@@ -192,12 +192,12 @@  discard block
 block discarded – undo
192 192
         return $this->updateString($string);
193 193
     }
194 194
 
195
-   /**
196
-    * Get the position of a substring in the string.
197
-    * 
198
-    * @param string $needle
199
-    * @return int|bool The zero-based position, or false if not found.
200
-    */
195
+    /**
196
+     * Get the position of a substring in the string.
197
+     * 
198
+     * @param string $needle
199
+     * @return int|bool The zero-based position, or false if not found.
200
+     */
201 201
     public function getSubstrPosition(string $needle)
202 202
     {
203 203
         return mb_strpos($this->subject, $needle);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
     public function updateString(string $subject) : bool
89 89
     {
90 90
         // avoid triggering an update if there are no changes in the string
91
-        if($subject === $this->subject)
91
+        if ($subject === $this->subject)
92 92
         {
93 93
             return false;
94 94
         }
95 95
         
96
-        if($this->updating)
96
+        if ($this->updating)
97 97
         {
98 98
             throw new Mailcode_Exception(
99 99
                 'Cannot modify subject string during update',
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         $this->subject = $subject;
108 108
         $this->length = mb_strlen($this->subject);
109 109
         
110
-        foreach($this->listeners as $listener)
110
+        foreach ($this->listeners as $listener)
111 111
         {
112 112
             $listener($this);
113 113
         }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
     {
143 143
         self::$listenerCounter++;
144 144
         
145
-        if(!is_callable($callback))
145
+        if (!is_callable($callback))
146 146
         {
147 147
             throw new Mailcode_Exception(
148 148
                 'Not a valid callable',
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     */
173 173
     public function removeListener(int $listenerID) : void
174 174
     {
175
-        if(isset($this->listeners[$listenerID]))
175
+        if (isset($this->listeners[$listenerID]))
176 176
         {
177 177
             unset($this->listeners[$listenerID]);
178 178
         }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         return mb_strpos($this->subject, $needle);
204 204
     }
205 205
     
206
-    public function getSubstr(int $start, ?int $length=null) : string
206
+    public function getSubstr(int $start, ?int $length = null) : string
207 207
     {
208 208
         return mb_substr($this->subject, $start, $length);
209 209
     }
Please login to merge, or discard this patch.