Passed
Push — master ( 827600...d1e019 )
by Sebastian
04:24
created
src/Mailcode/Factory.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @param string $formatString A date format string, or empty string for default.
48 48
      * @return Mailcode_Commands_Command_ShowDate
49 49
      */
50
-    public static function showDate(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowDate
50
+    public static function showDate(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowDate
51 51
     {
52 52
         return self::$commandSets->show()->showDate($variableName, $formatString);
53 53
     }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     * 
75 75
     * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED
76 76
     */
77
-    public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable
77
+    public static function setVar(string $variableName, string $value, bool $quoteValue = true) : Mailcode_Commands_Command_SetVariable
78 78
     {
79 79
         return self::$commandSets->set()->setVar($variableName, $value, $quoteValue);
80 80
     }
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
         return self::$commandSets->if()->end();
108 108
     }
109 109
     
110
-    public static function if(string $condition, string $type='') : Mailcode_Commands_Command_If
110
+    public static function if (string $condition, string $type = '') : Mailcode_Commands_Command_If
111 111
     {
112 112
         return self::$commandSets->if()->if($condition, $type);
113 113
     }
114 114
     
115
-    public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable
115
+    public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable
116 116
     {
117 117
         return self::$commandSets->if()->ifVar($variable, $operand, $value, $quoteValue);
118 118
     }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         return self::$commandSets->if()->ifVarString($variable, $operand, $value);
123 123
     }
124 124
     
125
-    public static function ifVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable
125
+    public static function ifVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable
126 126
     {
127 127
         return self::$commandSets->if()->ifVarEquals($variable, $value, $quoteValue);
128 128
     }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         return self::$commandSets->if()->ifVarEqualsString($variable, $value);
133 133
     }
134 134
     
135
-    public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable
135
+    public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable
136 136
     {
137 137
         return self::$commandSets->if()->ifVarNotEquals($variable, $value, $quoteValue);
138 138
     }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         return self::$commandSets->if()->ifVarNotEqualsString($variable, $value);
143 143
     }
144 144
     
145
-    public static function elseIf(string $condition, string $type='') : Mailcode_Commands_Command_ElseIf
145
+    public static function elseIf (string $condition, string $type = '') : Mailcode_Commands_Command_ElseIf
146 146
     {
147 147
         return self::$commandSets->elseIf()->elseIf($condition, $type);
148 148
     }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         return self::$commandSets->elseIf()->elseIfNotEmpty($variable);
158 158
     }
159 159
     
160
-    public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable
160
+    public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable
161 161
     {
162 162
         return self::$commandSets->elseIf()->elseIfVar($variable, $operand, $value, $quoteValue);
163 163
     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         return self::$commandSets->elseIf()->elseIfVarString($variable, $operand, $value);
168 168
     }
169 169
     
170
-    public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable
170
+    public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable
171 171
     {
172 172
         return self::$commandSets->elseIf()->elseIfVarEquals($variable, $value, $quoteValue);
173 173
     }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         return self::$commandSets->elseIf()->elseIfVarEqualsString($variable, $value);
178 178
     }
179 179
     
180
-    public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable
180
+    public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable
181 181
     {
182 182
         return self::$commandSets->elseIf()->elseIfVarNotEquals($variable, $value, $quoteValue);
183 183
     }
@@ -187,27 +187,27 @@  discard block
 block discarded – undo
187 187
         return self::$commandSets->elseIf()->elseIfVarNotEqualsString($variable, $value);
188 188
     }
189 189
 
190
-    public static function ifBeginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_BeginsWith
190
+    public static function ifBeginsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_BeginsWith
191 191
     {
192 192
         return self::$commandSets->if()->ifBeginsWith($variable, $search, $caseInsensitive);
193 193
     }
194 194
 
195
-    public static function ifEndsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_EndsWith
195
+    public static function ifEndsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_EndsWith
196 196
     {
197 197
         return self::$commandSets->if()->ifEndsWith($variable, $search, $caseInsensitive);
198 198
     }
199 199
 
200
-    public static function elseIfBeginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_BeginsWith
200
+    public static function elseIfBeginsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_BeginsWith
201 201
     {
202 202
         return self::$commandSets->elseIf()->elseIfBeginsWith($variable, $search, $caseInsensitive);
203 203
     }
204 204
     
205
-    public static function elseIfEndsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_EndsWith
205
+    public static function elseIfEndsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_EndsWith
206 206
     {
207 207
         return self::$commandSets->elseIf()->elseIfEndsWith($variable, $search, $caseInsensitive);
208 208
     }
209 209
     
210
-    public static function ifContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains
210
+    public static function ifContains(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_Contains
211 211
     {
212 212
         return self::$commandSets->if()->ifContains($variable, array($search), $caseInsensitive);
213 213
     }
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
     * @param bool $caseInsensitive
221 221
     * @return Mailcode_Commands_Command_If_Contains
222 222
     */
223
-    public static function ifContainsAny(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains
223
+    public static function ifContainsAny(string $variable, array $searchTerms, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_Contains
224 224
     {
225 225
         return self::$commandSets->if()->ifContains($variable, $searchTerms, $caseInsensitive);
226 226
     }
227 227
     
228
-    public static function elseIfContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains
228
+    public static function elseIfContains(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_Contains
229 229
     {
230 230
         return self::$commandSets->elseIf()->elseIfContains($variable, array($search), $caseInsensitive);
231 231
     }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     * @param bool $caseInsensitive
239 239
     * @return Mailcode_Commands_Command_ElseIf_Contains
240 240
     */
241
-    public static function elseIfContainsAny(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains
241
+    public static function elseIfContainsAny(string $variable, array $searchTerms, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_Contains
242 242
     {
243 243
         return self::$commandSets->elseIf()->elseIfContains($variable, $searchTerms, $caseInsensitive);
244 244
     }
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
         return self::$commandSets->if()->ifNotEmpty($variable);
254 254
     }
255 255
     
256
-    public static function for(string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For
256
+    public static function for (string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For
257 257
     {
258 258
         return self::$commandSets->misc()->for($sourceVariable, $loopVariable);
259 259
     }
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
     
294 294
     public static function init() : void
295 295
     {
296
-        if(!isset(self::$commandSets))
296
+        if (!isset(self::$commandSets))
297 297
         {
298 298
             self::$commandSets = new Mailcode_Factory_CommandSets();
299 299
         }
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/MarkVariables.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
     
41 41
     public function setTemplate(string $template) : void
42 42
     {
43
-        if(substr_count($template, '%s') !== 1)
43
+        if (substr_count($template, '%s') !== 1)
44 44
         {
45 45
             throw new Mailcode_Exception(
46 46
                 'Invalid tag template',
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatting.php 1 patch
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.
src/Mailcode/StringContainer.php 1 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.
src/Mailcode/Parser/Safeguard/Formatter/FormatType.php 1 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/Formatter/ReplacerType.php 1 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.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         
78 78
         $instance = new $class($this, $placeholder);
79 79
         
80
-        if($instance instanceof Mailcode_Parser_Safeguard_Formatter_Location)
80
+        if ($instance instanceof Mailcode_Parser_Safeguard_Formatter_Location)
81 81
         {
82 82
             return $instance;
83 83
         }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         
106 106
         $result = array();
107 107
         
108
-        foreach($placeholders as $placeholder)
108
+        foreach ($placeholders as $placeholder)
109 109
         {
110 110
             $result[] = $this->createLocation($placeholder);
111 111
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     {
124 124
         $eol = ConvertHelper::detectEOLCharacter($subject);
125 125
         
126
-        if($eol)
126
+        if ($eol)
127 127
         {
128 128
             $this->log(sprintf(
129 129
                 'Detected EOL character: %s.', 
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/SingleLines/Location.php 1 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.