Passed
Push — master ( 75ee28...758f58 )
by Sebastian
04:00
created
src/Mailcode/Translator/Syntax/ApacheVelocity/ShowVariable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
         $varName = ltrim($command->getVariableName(), '$');
26 26
 
27 27
         // Automatically URL escape the variable if it's in an URL.
28
-        if($command->isURLEncoded())
28
+        if ($command->isURLEncoded())
29 29
         {
30 30
             return sprintf(
31 31
                 '${esc.url($%s)}',
Please login to merge, or discard this patch.
src/Mailcode/Translator/Syntax/ApacheVelocity/ShowDate.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
         $varName = ltrim($command->getVariableName(), '$');
57 57
         $javaFormat = $this->translateFormat($command->getFormatString());
58 58
 
59
-        if(empty($internalFormat))
59
+        if (empty($internalFormat))
60 60
         {
61 61
             $internalFormat = self::DEFAULT_INTERNAL_FORMAT;
62 62
         }
63 63
 
64
-        if($command->isURLEncoded())
64
+        if ($command->isURLEncoded())
65 65
         {
66 66
             return sprintf(
67 67
                 '${esc.url($date.format("%s", $date.toDate("%s", $%s)))}',
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
         $chars = ConvertHelper::string2array($formatString);
85 85
         $result = array();
86 86
         
87
-        foreach($chars as $char)
87
+        foreach ($chars as $char)
88 88
         {
89
-            if(!isset($this->charTable[$char]))
89
+            if (!isset($this->charTable[$char]))
90 90
             {
91 91
                 throw new Mailcode_Translator_Exception(
92 92
                     'Unknown date format string character',
Please login to merge, or discard this patch.
src/Mailcode/Translator/Syntax/ApacheVelocity/ShowSnippet.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     {
30 30
         $varName = ltrim($command->getVariableName(), '$');
31 31
 
32
-        if($command->isURLEncoded())
32
+        if ($command->isURLEncoded())
33 33
         {
34 34
             return sprintf(
35 35
                 '${esc.url($%s.replaceAll($esc.newline, "<br/>"))}',
Please login to merge, or discard this patch.
src/Mailcode/Translator/Syntax/ApacheVelocity/ShowNumber.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             $locale
41 41
         );
42 42
 
43
-        if($command->isURLEncoded())
43
+        if ($command->isURLEncoded())
44 44
         {
45 45
             return sprintf(
46 46
                 '${esc.url($%s)}',
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
             $dc = '_';
93 93
         }
94 94
 
95
-        $type = $th . $dc;
95
+        $type = $th.$dc;
96 96
 
97 97
         if (isset($this->typeLocales[$type])) {
98 98
             return $this->typeLocales[$type];
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
     {
106 106
         $result = '#';
107 107
 
108
-        if($format->hasThousandsSeparator())
108
+        if ($format->hasThousandsSeparator())
109 109
         {
110 110
             $result = '#,###';
111 111
         }
112 112
 
113
-        if($format->hasDecimals())
113
+        if ($format->hasDecimals())
114 114
         {
115 115
             $result .= '.'.str_repeat('#', $format->getDecimals());
116 116
         }
Please login to merge, or discard this patch.
src/Mailcode/Factory.php 1 patch
Spacing   +21 added lines, -21 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
     }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * @param string $formatString A number format string, or empty string for default.
61 61
      * @return Mailcode_Commands_Command_ShowNumber
62 62
      */
63
-    public static function showNumber(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowNumber
63
+    public static function showNumber(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowNumber
64 64
     {
65 65
         return self::$commandSets->show()->showNumber($variableName, $formatString);
66 66
     }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     * 
88 88
     * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED
89 89
     */
90
-    public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable
90
+    public static function setVar(string $variableName, string $value, bool $quoteValue = true) : Mailcode_Commands_Command_SetVariable
91 91
     {
92 92
         return self::$commandSets->set()->setVar($variableName, $value, $quoteValue);
93 93
     }
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
         return self::$commandSets->if()->end();
121 121
     }
122 122
     
123
-    public static function if(string $condition, string $type='') : Mailcode_Commands_Command_If
123
+    public static function if (string $condition, string $type = '') : Mailcode_Commands_Command_If
124 124
     {
125 125
         return self::$commandSets->if()->if($condition, $type);
126 126
     }
127 127
     
128
-    public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable
128
+    public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable
129 129
     {
130 130
         return self::$commandSets->if()->ifVar($variable, $operand, $value, $quoteValue);
131 131
     }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         return self::$commandSets->if()->ifVarString($variable, $operand, $value);
136 136
     }
137 137
     
138
-    public static function ifVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable
138
+    public static function ifVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable
139 139
     {
140 140
         return self::$commandSets->if()->ifVarEquals($variable, $value, $quoteValue);
141 141
     }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         return self::$commandSets->if()->ifVarEqualsString($variable, $value);
146 146
     }
147 147
     
148
-    public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable
148
+    public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable
149 149
     {
150 150
         return self::$commandSets->if()->ifVarNotEquals($variable, $value, $quoteValue);
151 151
     }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         return self::$commandSets->if()->ifVarNotEqualsString($variable, $value);
156 156
     }
157 157
     
158
-    public static function elseIf(string $condition, string $type='') : Mailcode_Commands_Command_ElseIf
158
+    public static function elseIf (string $condition, string $type = '') : Mailcode_Commands_Command_ElseIf
159 159
     {
160 160
         return self::$commandSets->elseIf()->elseIf($condition, $type);
161 161
     }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         return self::$commandSets->elseIf()->elseIfNotEmpty($variable);
171 171
     }
172 172
     
173
-    public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable
173
+    public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable
174 174
     {
175 175
         return self::$commandSets->elseIf()->elseIfVar($variable, $operand, $value, $quoteValue);
176 176
     }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         return self::$commandSets->elseIf()->elseIfVarString($variable, $operand, $value);
181 181
     }
182 182
     
183
-    public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable
183
+    public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable
184 184
     {
185 185
         return self::$commandSets->elseIf()->elseIfVarEquals($variable, $value, $quoteValue);
186 186
     }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         return self::$commandSets->elseIf()->elseIfVarEqualsString($variable, $value);
191 191
     }
192 192
     
193
-    public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable
193
+    public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable
194 194
     {
195 195
         return self::$commandSets->elseIf()->elseIfVarNotEquals($variable, $value, $quoteValue);
196 196
     }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         return self::$commandSets->elseIf()->elseIfVarNotEqualsString($variable, $value);
201 201
     }
202 202
 
203
-    public static function ifBeginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_BeginsWith
203
+    public static function ifBeginsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_BeginsWith
204 204
     {
205 205
         return self::$commandSets->if()->ifBeginsWith($variable, $search, $caseInsensitive);
206 206
     }
@@ -220,22 +220,22 @@  discard block
 block discarded – undo
220 220
         return self::$commandSets->if()->ifVarEqualsNumber($variable, $number);
221 221
     }
222 222
 
223
-    public static function ifEndsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_EndsWith
223
+    public static function ifEndsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_EndsWith
224 224
     {
225 225
         return self::$commandSets->if()->ifEndsWith($variable, $search, $caseInsensitive);
226 226
     }
227 227
 
228
-    public static function elseIfBeginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_BeginsWith
228
+    public static function elseIfBeginsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_BeginsWith
229 229
     {
230 230
         return self::$commandSets->elseIf()->elseIfBeginsWith($variable, $search, $caseInsensitive);
231 231
     }
232 232
     
233
-    public static function elseIfEndsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_EndsWith
233
+    public static function elseIfEndsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_EndsWith
234 234
     {
235 235
         return self::$commandSets->elseIf()->elseIfEndsWith($variable, $search, $caseInsensitive);
236 236
     }
237 237
     
238
-    public static function ifContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains
238
+    public static function ifContains(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_Contains
239 239
     {
240 240
         return self::$commandSets->if()->ifContains($variable, array($search), $caseInsensitive);
241 241
     }
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
     * @param bool $caseInsensitive
264 264
     * @return Mailcode_Commands_Command_If_Contains
265 265
     */
266
-    public static function ifContainsAny(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains
266
+    public static function ifContainsAny(string $variable, array $searchTerms, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_Contains
267 267
     {
268 268
         return self::$commandSets->if()->ifContains($variable, $searchTerms, $caseInsensitive);
269 269
     }
270 270
     
271
-    public static function elseIfContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains
271
+    public static function elseIfContains(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_Contains
272 272
     {
273 273
         return self::$commandSets->elseIf()->elseIfContains($variable, array($search), $caseInsensitive);
274 274
     }
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     * @param bool $caseInsensitive
282 282
     * @return Mailcode_Commands_Command_ElseIf_Contains
283 283
     */
284
-    public static function elseIfContainsAny(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains
284
+    public static function elseIfContainsAny(string $variable, array $searchTerms, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_Contains
285 285
     {
286 286
         return self::$commandSets->elseIf()->elseIfContains($variable, $searchTerms, $caseInsensitive);
287 287
     }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
         return self::$commandSets->if()->ifNotEmpty($variable);
297 297
     }
298 298
     
299
-    public static function for(string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For
299
+    public static function for (string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For
300 300
     {
301 301
         return self::$commandSets->misc()->for($sourceVariable, $loopVariable);
302 302
     }
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
     public static function init() : void
338 338
     {
339
-        if(!isset(self::$commandSets))
339
+        if (!isset(self::$commandSets))
340 340
         {
341 341
             self::$commandSets = new Mailcode_Factory_CommandSets();
342 342
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement/Info.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         $operand = $this->getOperandByIndex(1);
49 49
         $value = $this->getTokenByIndex(2);
50 50
         
51
-        if($variable && $operand && $value && $operand->isAssignment())
51
+        if ($variable && $operand && $value && $operand->isAssignment())
52 52
         {
53 53
             return true;
54 54
         }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $operand = $this->getOperandByIndex(1);
68 68
         $value = $this->getTokenByIndex(2);
69 69
         
70
-        if($variable && $operand && $value && $operand->isComparator())
70
+        if ($variable && $operand && $value && $operand->isComparator())
71 71
         {
72 72
             return true;
73 73
         }
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
     {
85 85
         $result = array();
86 86
         
87
-        foreach($this->tokens as $token)
87
+        foreach ($this->tokens as $token)
88 88
         {
89
-            if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
89
+            if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
90 90
             {
91 91
                 $result[] = $token->getVariable();
92 92
             }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     {
108 108
         $token = $this->getTokenByIndex($index);
109 109
         
110
-        if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
110
+        if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
111 111
         {
112 112
             return $token;
113 113
         }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     {
128 128
         $token = $this->getTokenByIndex($index);
129 129
         
130
-        if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral)
130
+        if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral)
131 131
         {
132 132
             return $token;
133 133
         }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     {
148 148
         $token = $this->getTokenByIndex($index);
149 149
         
150
-        if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
150
+        if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
151 151
         {
152 152
             return $token;
153 153
         }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     {
168 168
         $token = $this->getTokenByIndex($index);
169 169
         
170
-        if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
170
+        if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
171 171
         {
172 172
             return $token;
173 173
         }
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     */
186 186
     public function getTokenByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token
187 187
     {
188
-        if(isset($this->tokens[$index]))
188
+        if (isset($this->tokens[$index]))
189 189
         {
190 190
             return $this->tokens[$index];
191 191
         }
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
     {
216 216
         $result = array();
217 217
         
218
-        foreach($this->tokens as $token)
218
+        foreach ($this->tokens as $token)
219 219
         {
220
-            if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral)
220
+            if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral)
221 221
             {
222 222
                 $result[] = $token;
223 223
             }
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
     {
239 239
         $result = array();
240 240
 
241
-        foreach($this->tokens as $token)
241
+        foreach ($this->tokens as $token)
242 242
         {
243
-            if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
243
+            if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
244 244
             {
245 245
                 $result[] = $token;
246 246
             }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 
256 256
         foreach ($keywords as $keyword)
257 257
         {
258
-            if($keyword->isURLEncoded())
258
+            if ($keyword->isURLEncoded())
259 259
             {
260 260
                 return true;
261 261
             }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 
284 284
     public function addURLEncoding() : Mailcode_Parser_Statement_Info
285 285
     {
286
-        if(!$this->hasURLEncoding())
286
+        if (!$this->hasURLEncoding())
287 287
         {
288 288
             $this->tokenizer->appendKeyword('urlencode');
289 289
             $this->tokens = $this->tokenizer->getTokens();
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement/Tokenizer.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
     {
139 139
         $result = array();
140 140
         
141
-        foreach($this->tokensOrdered as $token)
141
+        foreach ($this->tokensOrdered as $token)
142 142
         {
143
-            if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown)
143
+            if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown)
144 144
             {
145 145
                 $result[] = $token;
146 146
             }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     {
154 154
         $unknown = $this->getUnknown();
155 155
         
156
-        if(!empty($unknown))
156
+        if (!empty($unknown))
157 157
         {
158 158
             return array_shift($unknown);
159 159
         }
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
     {
166 166
         $parts = array();
167 167
         
168
-        foreach($this->tokensOrdered as $token)
168
+        foreach ($this->tokensOrdered as $token)
169 169
         {
170 170
             $string = $token->getNormalized();
171 171
             
172
-            if($string != '')
172
+            if ($string != '')
173 173
             {
174 174
                 $parts[] = $string;
175 175
             }
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
     {
183 183
         $this->tokenized = trim($statement);
184 184
         
185
-        foreach($this->tokenCategories as $token)
185
+        foreach ($this->tokenCategories as $token)
186 186
         {
187 187
             $method = 'tokenize_'.$token;
188 188
             
189
-            if(!method_exists($this, $method))
189
+            if (!method_exists($this, $method))
190 190
             {
191 191
                 throw new Mailcode_Exception(
192 192
                     'Unknown statement token.',
@@ -210,12 +210,12 @@  discard block
 block discarded – undo
210 210
     * @param string $matchedText
211 211
     * @param mixed $subject
212 212
     */
213
-    protected function registerToken(string $type, string $matchedText, $subject=null) : void
213
+    protected function registerToken(string $type, string $matchedText, $subject = null) : void
214 214
     {
215 215
         $this->tokensTemporary[] = $this->createToken($type, $matchedText, $subject);
216 216
     }
217 217
 
218
-    protected function createToken(string $type, string $matchedText, $subject=null) : Mailcode_Parser_Statement_Tokenizer_Token
218
+    protected function createToken(string $type, string $matchedText, $subject = null) : Mailcode_Parser_Statement_Tokenizer_Token
219 219
     {
220 220
         $tokenID = $this->generateID();
221 221
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
         $token = $this->appendToken('Keyword', $name);
238 238
 
239
-        if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
239
+        if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
240 240
         {
241 241
             return $token;
242 242
         }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 
256 256
         foreach ($this->tokensOrdered as $checkToken)
257 257
         {
258
-            if($checkToken->getID() !== $tokenID)
258
+            if ($checkToken->getID() !== $tokenID)
259 259
             {
260 260
                 $keep[] = $checkToken;
261 261
             }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         return $this;
267 267
     }
268 268
 
269
-    protected function appendToken(string $type, string $matchedText, $subject=null) : Mailcode_Parser_Statement_Tokenizer_Token
269
+    protected function appendToken(string $type, string $matchedText, $subject = null) : Mailcode_Parser_Statement_Tokenizer_Token
270 270
     {
271 271
         $token = $this->createToken($type, $matchedText, $subject);
272 272
 
@@ -277,9 +277,9 @@  discard block
 block discarded – undo
277 277
     
278 278
     protected function getTokenByID(string $tokenID) : ?Mailcode_Parser_Statement_Tokenizer_Token
279 279
     {
280
-        foreach($this->tokensTemporary as $token)
280
+        foreach ($this->tokensTemporary as $token)
281 281
         {
282
-            if($token->getID() === $tokenID)
282
+            if ($token->getID() === $tokenID)
283 283
             {
284 284
                 return $token;
285 285
             }
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
     
306 306
     protected function tokenize_keywords() : void
307 307
     {
308
-        foreach($this->keywords as $keyword)
308
+        foreach ($this->keywords as $keyword)
309 309
         {
310
-            if(strstr($this->tokenized, $keyword))
310
+            if (strstr($this->tokenized, $keyword))
311 311
             {
312 312
                 $this->registerToken('Keyword', $keyword);
313 313
             }
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
         // over that could not be tokenized.
322 322
         $parts = \AppUtils\ConvertHelper::explodeTrim($this->delimiter, $this->tokenized);
323 323
 
324
-        foreach($parts as $part)
324
+        foreach ($parts as $part)
325 325
         {
326 326
             $token = $this->getTokenByID($part);
327 327
             
328 328
             // if the entry is a token, simply add it.
329
-            if($token)
329
+            if ($token)
330 330
             {
331 331
                 $this->tokensOrdered[] = $token;
332 332
             }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
     {
343 343
         $vars = Mailcode::create()->findVariables($this->tokenized)->getGroupedByHash();
344 344
         
345
-        foreach($vars as $var)
345
+        foreach ($vars as $var)
346 346
         {
347 347
             $this->registerToken('Variable', $var->getMatchedText(), $var);
348 348
         }
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
     
351 351
     protected function tokenize_operands() : void
352 352
     {
353
-        foreach($this->operands as $operand)
353
+        foreach ($this->operands as $operand)
354 354
         {
355
-            if(strstr($this->tokenized, $operand))
355
+            if (strstr($this->tokenized, $operand))
356 356
             {
357 357
                 $this->registerToken('Operand', $operand);
358 358
             }
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
         $matches = array();
365 365
         preg_match_all('/"(.*)"/sxU', $this->tokenized, $matches, PREG_PATTERN_ORDER);
366 366
         
367
-        foreach($matches[0] as $match)
367
+        foreach ($matches[0] as $match)
368 368
         {
369 369
             $this->registerToken('StringLiteral', $match);
370 370
         }
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
         $matches = array();
376 376
         preg_match_all('/-*[0-9]+\s*[.,]\s*[0-9]+|-*[0-9]+/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER);
377 377
         
378
-        foreach($matches[0] as $match)
378
+        foreach ($matches[0] as $match)
379 379
         {
380 380
             $this->registerToken('Number', $match);
381 381
         }
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
     {
393 393
         static $alphas;
394 394
         
395
-        if(!isset($alphas))
395
+        if (!isset($alphas))
396 396
         {
397 397
             $alphas = range('A', 'Z');
398 398
         }
@@ -401,12 +401,12 @@  discard block
 block discarded – undo
401 401
         
402 402
         $result = '';
403 403
         
404
-        for($i=0; $i < $amount; $i++)
404
+        for ($i = 0; $i < $amount; $i++)
405 405
         {
406 406
             $result .= $alphas[array_rand($alphas)];
407 407
         }
408 408
         
409
-        if(!in_array($result, self::$ids))
409
+        if (!in_array($result, self::$ids))
410 410
         {
411 411
             self::$ids[] = $result;
412 412
             return $result;
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard.php 1 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/Commands/Command.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      */
118 118
     protected $meta;
119 119
 
120
-    public function __construct(string $type='', string $paramsString='', string $matchedText='')
120
+    public function __construct(string $type = '', string $paramsString = '', string $matchedText = '')
121 121
     {
122 122
         $this->type = $type;
123 123
         $this->paramsString = html_entity_decode($paramsString);
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     {
214 214
         $this->requireNonDummy();
215 215
         
216
-        if($this->hash === '') {
216
+        if ($this->hash === '') {
217 217
             $this->hash = md5($this->matchedText);
218 218
         }
219 219
         
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     
223 223
     protected function requireNonDummy() : void
224 224
     {
225
-        if(!$this->isDummy())
225
+        if (!$this->isDummy())
226 226
         {
227 227
             return;
228 228
         }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
     
242 242
     protected function validate() : \AppUtils\OperationResult
243 243
     {
244
-        if(!$this->validated)
244
+        if (!$this->validated)
245 245
         {
246 246
             $this->requireNonDummy();
247 247
             $this->validateSyntax();
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
     
255 255
     public function getValidationResult() :  \AppUtils\OperationResult
256 256
     {
257
-        if(isset($this->validationResult)) 
257
+        if (isset($this->validationResult)) 
258 258
         {
259 259
             return $this->validationResult;
260 260
         }
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
     {
271 271
         $validations = array_merge($this->validations, $this->getValidations());
272 272
         
273
-        foreach($validations as $validation)
273
+        foreach ($validations as $validation)
274 274
         {
275 275
             // break off at the first validation issue
276
-            if(!$this->validateSyntaxMethod($validation))
276
+            if (!$this->validateSyntaxMethod($validation))
277 277
             {
278 278
                 return;
279 279
             }
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
     {
285 285
         $method = 'validateSyntax_'.$validation;
286 286
         
287
-        if(!method_exists($this, $method))
287
+        if (!method_exists($this, $method))
288 288
         {
289 289
             throw new Mailcode_Exception(
290 290
                 'Missing validation method ['.$validation.']',
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
     
310 310
     protected function validateSyntax_params_empty() : void
311 311
     {
312
-        if(!$this->requiresParameters())
312
+        if (!$this->requiresParameters())
313 313
         {
314 314
             return;
315 315
         }
316 316
         
317
-        if(empty($this->paramsString))
317
+        if (empty($this->paramsString))
318 318
         {
319 319
             $this->validationResult->makeError(
320 320
                 t('Parameters have to be specified.'),
@@ -326,14 +326,14 @@  discard block
 block discarded – undo
326 326
     
327 327
     protected function validateSyntax_params_keywords() : void
328 328
     {
329
-        if(!$this->supportsLogicKeywords())
329
+        if (!$this->supportsLogicKeywords())
330 330
         {
331 331
             return;
332 332
         }
333 333
         
334 334
         $this->logicKeywords = new Mailcode_Commands_LogicKeywords($this, $this->paramsString);
335 335
         
336
-        if(!$this->logicKeywords->isValid())
336
+        if (!$this->logicKeywords->isValid())
337 337
         {
338 338
             $this->validationResult->makeError(
339 339
                 t('Invalid parameters:').' '.$this->logicKeywords->getErrorMessage(),
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
     
349 349
     protected function validateSyntax_params_parse() : void
350 350
     {
351
-        if(!$this->requiresParameters())
351
+        if (!$this->requiresParameters())
352 352
         {
353 353
             return;
354 354
         }
355 355
         
356 356
         $this->params = $this->mailcode->getParser()->createStatement($this->paramsString);
357 357
         
358
-        if(!$this->params->isValid())
358
+        if (!$this->params->isValid())
359 359
         {
360 360
             $error = $this->params->getValidationResult();
361 361
             
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
     
373 373
     protected function validateSyntax_type_supported() : void
374 374
     {
375
-        if(!$this->supportsType() || empty($this->type))
375
+        if (!$this->supportsType() || empty($this->type))
376 376
         {
377 377
             return;
378 378
         }
379 379
         
380 380
         $types = $this->getSupportedTypes();
381 381
 
382
-        if(!in_array($this->type, $types))
382
+        if (!in_array($this->type, $types))
383 383
         {
384 384
             $this->validationResult->makeError(
385 385
                 t('The command addon %1$s is not supported.', $this->type).' '.
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
     
394 394
     protected function validateSyntax_type_unsupported() : void
395 395
     {
396
-        if($this->supportsType() || empty($this->type))
396
+        if ($this->supportsType() || empty($this->type))
397 397
         {
398 398
             return;
399 399
         }
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
     
412 412
     public function getType() : string
413 413
     {
414
-        if($this->supportsType())
414
+        if ($this->supportsType())
415 415
         {
416 416
             return $this->type;
417 417
         }
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
     
432 432
     public function getHighlighted() : string
433 433
     {
434
-        if(!$this->isValid())
434
+        if (!$this->isValid())
435 435
         {
436 436
             return '';
437 437
         }
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     
443 443
     public function getParamsString() : string
444 444
     {
445
-        if($this->requiresParameters())
445
+        if ($this->requiresParameters())
446 446
         {
447 447
             return $this->paramsString;
448 448
         }
@@ -479,22 +479,22 @@  discard block
 block discarded – undo
479 479
     
480 480
     public final function getCommandType() : string
481 481
     {
482
-        if($this instanceof Mailcode_Commands_Command_Type_Closing)
482
+        if ($this instanceof Mailcode_Commands_Command_Type_Closing)
483 483
         {
484 484
             return 'Closing';
485 485
         }
486 486
         
487
-        if($this instanceof Mailcode_Commands_Command_Type_Opening)
487
+        if ($this instanceof Mailcode_Commands_Command_Type_Opening)
488 488
         {
489 489
             return 'Opening';
490 490
         }
491 491
         
492
-        if($this instanceof Mailcode_Commands_Command_Type_Sibling)
492
+        if ($this instanceof Mailcode_Commands_Command_Type_Sibling)
493 493
         {
494 494
             return 'Sibling';
495 495
         }
496 496
         
497
-        if($this instanceof Mailcode_Commands_Command_Type_Standalone)
497
+        if ($this instanceof Mailcode_Commands_Command_Type_Standalone)
498 498
         {
499 499
             return 'Standalone';
500 500
         }
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
     
545 545
     public function getLogicKeywords() : Mailcode_Commands_LogicKeywords
546 546
     {
547
-        if($this->supportsLogicKeywords() && isset($this->logicKeywords))
547
+        if ($this->supportsLogicKeywords() && isset($this->logicKeywords))
548 548
         {
549 549
             return $this->logicKeywords;
550 550
         }
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
     */
579 579
     public function getTranslationParam(string $name)
580 580
     {
581
-        if(isset($this->translationParams[$name]))
581
+        if (isset($this->translationParams[$name]))
582 582
         {
583 583
             return $this->translationParams[$name];
584 584
         }
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
      */
604 604
     public function getMeta(string $name)
605 605
     {
606
-        if(isset($this->meta[$name]))
606
+        if (isset($this->meta[$name]))
607 607
         {
608 608
             return $this->meta[$name];
609 609
         }
@@ -615,9 +615,9 @@  discard block
 block discarded – undo
615 615
      * @param bool $encoding
616 616
      * @return $this
617 617
      */
618
-    public function setURLEncoding(bool $encoding=true)
618
+    public function setURLEncoding(bool $encoding = true)
619 619
     {
620
-        if(!$this->supportsURLEncoding())
620
+        if (!$this->supportsURLEncoding())
621 621
         {
622 622
             throw new Mailcode_Exception(
623 623
                 'Command does not support URL encoding.',
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
             );
630 630
         }
631 631
 
632
-        if($encoding)
632
+        if ($encoding)
633 633
         {
634 634
             $this->params->getInfo()->addURLEncoding();
635 635
         }
Please login to merge, or discard this patch.