Passed
Push — master ( 2f714f...1c67eb )
by Sebastian
02:15
created
src/Mailcode/Variables/Variable.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     
97 97
     public function getHash() : string
98 98
     {
99
-        if(empty($this->hash))
99
+        if (empty($this->hash))
100 100
         {
101 101
             $this->hash = md5($this->matchedText);
102 102
         }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     
112 112
     public function getValidationResult() : OperationResult
113 113
     {
114
-        if(isset($this->validationResult))
114
+        if (isset($this->validationResult))
115 115
         {
116 116
             return $this->validationResult;
117 117
         }
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 
126 126
     protected function validate() : void
127 127
     {
128
-        foreach($this->validations as $validation)
128
+        foreach ($this->validations as $validation)
129 129
         {
130 130
             $method = 'validate_'.$validation;
131 131
             
132
-            if(!method_exists($this, $method))
132
+            if (!method_exists($this, $method))
133 133
             {
134 134
                 throw new Mailcode_Exception(
135 135
                     'Unknown validation method',
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             
145 145
             $this->$method();
146 146
             
147
-            if(!$this->validationResult->isValid())
147
+            if (!$this->validationResult->isValid())
148 148
             {
149 149
                 return;
150 150
             }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     
174 174
     protected function validateNumber(string $value, int $errorCode) : void
175 175
     {
176
-        if(!is_numeric(substr($value, 0, 1)))
176
+        if (!is_numeric(substr($value, 0, 1)))
177 177
         {
178 178
             return;
179 179
         }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         $length = strlen($value);
194 194
         
195 195
         // trimming underscores does not change the length: no underscores at start or end of string.
196
-        if(strlen(trim($value, '_')) == $length)
196
+        if (strlen(trim($value, '_')) == $length)
197 197
         {
198 198
             return;
199 199
         }
Please login to merge, or discard this patch.
src/Mailcode/Variables/Collection.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $fullName = $this->fixName($fullName);
64 64
         
65
-        foreach($this->variables as $variable)
65
+        foreach ($this->variables as $variable)
66 66
         {
67
-            if($variable->getFullName() === $fullName)
67
+            if ($variable->getFullName() === $fullName)
68 68
             {
69 69
                 return true;
70 70
             }
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
         
88 88
         $collection = new Mailcode_Variables_Collection_Regular();
89 89
         
90
-        foreach($this->variables as $variable)
90
+        foreach ($this->variables as $variable)
91 91
         {
92
-            if($variable->getFullName() === $fullName)
92
+            if ($variable->getFullName() === $fullName)
93 93
             {
94 94
                 $collection->add($variable);
95 95
             }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     */
107 107
     protected function fixName(string $fullName) : string
108 108
     {
109
-        if(substr($fullName, 0, 1) === '$')
109
+        if (substr($fullName, 0, 1) === '$')
110 110
         {
111 111
             return $fullName;
112 112
         }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     {
125 125
         $entries = array();
126 126
         
127
-        foreach($this->variables as $variable)
127
+        foreach ($this->variables as $variable)
128 128
         {
129 129
             $entries[$variable->getHash()] = $variable;
130 130
         }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     {
142 142
         $entries = array();
143 143
         
144
-        foreach($this->variables as $variable)
144
+        foreach ($this->variables as $variable)
145 145
         {
146 146
             $entries[$variable->getFullName()] = $variable;
147 147
         }
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
     {
167 167
         $result = array();
168 168
         
169
-        foreach($this->variables as $variable)
169
+        foreach ($this->variables as $variable)
170 170
         {
171 171
             $name = $variable->getFullName();
172 172
             
173
-            if(!in_array($name, $result))
173
+            if (!in_array($name, $result))
174 174
             {
175 175
                 $result[] = $name;
176 176
             }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     {
210 210
         $variables = $collection->getGroupedByHash();
211 211
         
212
-        foreach($variables as $variable)
212
+        foreach ($variables as $variable)
213 213
         {
214 214
             $this->add($variable);
215 215
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     */
109 109
     public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard
110 110
     {
111
-        if(empty($delimiter))
111
+        if (empty($delimiter))
112 112
         {
113 113
             throw new Mailcode_Exception(
114 114
                 'Empty delimiter',
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
     * @param bool $highlighted
150 150
     * @return string[]string
151 151
     */
152
-    protected function getReplaces(bool $highlighted=false) : array
152
+    protected function getReplaces(bool $highlighted = false) : array
153 153
     {
154 154
         $placeholders = $this->getPlaceholders();
155 155
         
156 156
         $replaces = array();
157 157
         
158
-        foreach($placeholders as $placeholder)
158
+        foreach ($placeholders as $placeholder)
159 159
         {
160 160
             $replace = '';
161 161
             
162
-            if($highlighted)
162
+            if ($highlighted)
163 163
             {
164 164
                 $replace = $placeholder->getHighlightedText();
165 165
             }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     */
184 184
     public function getPlaceholders()
185 185
     {
186
-        if(isset($this->placeholders))
186
+        if (isset($this->placeholders))
187 187
         {
188 188
             return $this->placeholders;
189 189
         }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         
193 193
         $cmds = $this->getCollection()->getCommands();
194 194
         
195
-        foreach($cmds as $command)
195
+        foreach ($cmds as $command)
196 196
         {
197 197
             self::$counter++;
198 198
             
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         return $this->placeholders;
207 207
     }
208 208
     
209
-    protected function restore(string $string, bool $highlighted=false) : string
209
+    protected function restore(string $string, bool $highlighted = false) : string
210 210
     {
211 211
         $this->requireValidCollection();
212 212
         
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
         
215 215
         $placeholderStrings = array_keys($replaces);
216 216
         
217
-        foreach($placeholderStrings as $search)
217
+        foreach ($placeholderStrings as $search)
218 218
         {
219
-            if(!strstr($string, $search))
219
+            if (!strstr($string, $search))
220 220
             {
221 221
                 throw new Mailcode_Exception(
222 222
                     'Command placeholder not found',
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
     */
275 275
     public function getCollection() : Mailcode_Collection
276 276
     {
277
-        if(isset($this->collection))
277
+        if (isset($this->collection))
278 278
         {
279 279
             return $this->collection;
280 280
         }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
     */
297 297
     protected function requireValidCollection() : void
298 298
     {
299
-        if($this->getCollection()->isValid())
299
+        if ($this->getCollection()->isValid())
300 300
         {
301 301
             return;
302 302
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement/Info.php 1 patch
Spacing   +8 added lines, -8 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
             }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     {
100 100
         $token = $this->getTokenByIndex($index);
101 101
         
102
-        if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
102
+        if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
103 103
         {
104 104
             return $token;
105 105
         }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     {
112 112
         $token = $this->getTokenByIndex($index);
113 113
         
114
-        if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
114
+        if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
115 115
         {
116 116
             return $token;
117 117
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     {
124 124
         $token = $this->getTokenByIndex($index);
125 125
         
126
-        if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
126
+        if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
127 127
         {
128 128
             return $token;
129 129
         }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     
134 134
     public function getTokenByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token
135 135
     {
136
-        if(isset($this->tokens[$index]))
136
+        if (isset($this->tokens[$index]))
137 137
         {
138 138
             return $this->tokens[$index];
139 139
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement/Tokenizer/Token/Variable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
     
25 25
     public function getVariable() : Mailcode_Variables_Variable
26 26
     {
27
-        if($this->subject instanceof Mailcode_Variables_Variable)
27
+        if ($this->subject instanceof Mailcode_Variables_Variable)
28 28
         {
29 29
             return $this->subject;
30 30
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement/Tokenizer/Token.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
     * @param string $matchedText
41 41
     * @param mixed $subject
42 42
     */
43
-    public function __construct(string $tokenID, string $matchedText, $subject=null)
43
+    public function __construct(string $tokenID, string $matchedText, $subject = null)
44 44
     {
45 45
         $this->tokenID = $tokenID;
46 46
         $this->matchedText = $matchedText;
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement/Tokenizer.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
     {
135 135
         $result = array();
136 136
         
137
-        foreach($this->tokensOrdered as $token)
137
+        foreach ($this->tokensOrdered as $token)
138 138
         {
139
-            if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown)
139
+            if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown)
140 140
             {
141 141
                 $result[] = $token;
142 142
             }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     {
150 150
         $unknown = $this->getUnknown();
151 151
         
152
-        if(!empty($unknown))
152
+        if (!empty($unknown))
153 153
         {
154 154
             return array_shift($unknown);
155 155
         }
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
     {
162 162
         $parts = array();
163 163
         
164
-        foreach($this->tokensOrdered as $token)
164
+        foreach ($this->tokensOrdered as $token)
165 165
         {
166 166
             $string = $token->getNormalized();
167 167
             
168
-            if(!empty($string))
168
+            if (!empty($string))
169 169
             {
170 170
                 $parts[] = $string;
171 171
             }
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
     {
179 179
         $this->tokenized = trim($statement);
180 180
         
181
-        foreach($this->tokenCategories as $token)
181
+        foreach ($this->tokenCategories as $token)
182 182
         {
183 183
             $method = 'tokenize_'.$token;
184 184
             
185
-            if(!method_exists($this, $method))
185
+            if (!method_exists($this, $method))
186 186
             {
187 187
                 throw new Mailcode_Exception(
188 188
                     'Unknown statement token.',
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     * @param string $matchedText
207 207
     * @param mixed $subject
208 208
     */
209
-    protected function registerToken(string $type, string $matchedText, $subject=null) : void
209
+    protected function registerToken(string $type, string $matchedText, $subject = null) : void
210 210
     {
211 211
         $tokenID = $this->generateID();
212 212
         
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
     
224 224
     protected function getTokenByID(string $tokenID) : ?Mailcode_Parser_Statement_Tokenizer_Token
225 225
     {
226
-        foreach($this->tokensTemporary as $token)
226
+        foreach ($this->tokensTemporary as $token)
227 227
         {
228
-            if($token->getID() === $tokenID)
228
+            if ($token->getID() === $tokenID)
229 229
             {
230 230
                 return $token;
231 231
             }
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
     
242 242
     protected function tokenize_keywords() : void
243 243
     {
244
-        foreach($this->keywords as $keyword)
244
+        foreach ($this->keywords as $keyword)
245 245
         {
246
-            if(strstr($this->tokenized, $keyword))
246
+            if (strstr($this->tokenized, $keyword))
247 247
             {
248 248
                 $this->registerToken('Keyword', $keyword);
249 249
             }
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
         // over that could not be tokenized.
258 258
         $parts = \AppUtils\ConvertHelper::explodeTrim($this->delimiter, $this->tokenized);
259 259
 
260
-        foreach($parts as $part)
260
+        foreach ($parts as $part)
261 261
         {
262 262
             $token = $this->getTokenByID($part);
263 263
             
264 264
             // if the entry is a token, simply add it.
265
-            if($token)
265
+            if ($token)
266 266
             {
267 267
                 $this->tokensOrdered[] = $token;
268 268
             }
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
     {
279 279
         $vars = Mailcode::create()->findVariables($this->tokenized)->getGroupedByHash();
280 280
         
281
-        foreach($vars as $var)
281
+        foreach ($vars as $var)
282 282
         {
283 283
             $this->registerToken('Variable', $var->getMatchedText(), $var);
284 284
         }
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
     
287 287
     protected function tokenize_operands() : void
288 288
     {
289
-        foreach($this->operands as $operand)
289
+        foreach ($this->operands as $operand)
290 290
         {
291
-            if(strstr($this->tokenized, $operand))
291
+            if (strstr($this->tokenized, $operand))
292 292
             {
293 293
                 $this->registerToken('Operand', $operand);
294 294
             }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
         $matches = array();
301 301
         preg_match_all('/"(.*)"/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER);
302 302
         
303
-        foreach($matches[0] as $match)
303
+        foreach ($matches[0] as $match)
304 304
         {
305 305
             $this->registerToken('StringLiteral', $match);
306 306
         }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
         $matches = array();
312 312
         preg_match_all('/-*[0-9]+\s*[.,]\s*[0-9]+|-*[0-9]+/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER);
313 313
         
314
-        foreach($matches[0] as $match)
314
+        foreach ($matches[0] as $match)
315 315
         {
316 316
             $this->registerToken('Number', $match);
317 317
         }
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
     {
329 329
         static $alphas;
330 330
         
331
-        if(!isset($alphas))
331
+        if (!isset($alphas))
332 332
         {
333 333
             $alphas = range('A', 'Z');
334 334
         }
@@ -337,12 +337,12 @@  discard block
 block discarded – undo
337 337
         
338 338
         $result = '';
339 339
         
340
-        for($i=0; $i < $amount; $i++)
340
+        for ($i = 0; $i < $amount; $i++)
341 341
         {
342 342
             $result .= $alphas[array_rand($alphas)];
343 343
         }
344 344
         
345
-        if(!in_array($result, self::$ids))
345
+        if (!in_array($result, self::$ids))
346 346
         {
347 347
             self::$ids[] = $result;
348 348
             return $result;
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     
76 76
     public function getInfo() : Mailcode_Parser_Statement_Info
77 77
     {
78
-        if(isset($this->info))
78
+        if (isset($this->info))
79 79
         {
80 80
             return $this->info; 
81 81
         }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     
88 88
     protected function validate() : void
89 89
     {
90
-        if(!$this->tokenizer->hasTokens())
90
+        if (!$this->tokenizer->hasTokens())
91 91
         {
92 92
             $this->result->makeError(
93 93
                 t('Empty statement'),
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         
100 100
         $unknown = $this->tokenizer->getFirstUnknown();
101 101
         
102
-        if($unknown)
102
+        if ($unknown)
103 103
         {
104 104
             $this->result->makeError(
105 105
                t('Unquoted string literal found:').' ('.$unknown->getMatchedText().')',
Please login to merge, or discard this patch.
src/Mailcode/Collection.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         
98 98
         $errors = $this->errors;
99 99
         
100
-        if(!$result->isValid())
100
+        if (!$result->isValid())
101 101
         {
102 102
             $errors[] = new Mailcode_Collection_Error_Message(
103 103
                 '',
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
     {
140 140
         $hashes = array();
141 141
         
142
-        foreach($this->commands as $command)
142
+        foreach ($this->commands as $command)
143 143
         {
144 144
             $hash = $command->getHash();
145 145
             
146
-            if(!isset($hashes[$hash]))
146
+            if (!isset($hashes[$hash]))
147 147
             {
148 148
                 $hashes[$hash] = $command;
149 149
             }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     */
161 161
     public function addCommands(array $commands) : Mailcode_Collection
162 162
     {
163
-        foreach($commands as $command)
163
+        foreach ($commands as $command)
164 164
         {
165 165
             $this->addCommand($command);
166 166
         }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     {
180 180
         $collection = new Mailcode_Variables_Collection_Regular();
181 181
         
182
-        foreach($this->commands as $command)
182
+        foreach ($this->commands as $command)
183 183
         {
184 184
             $collection->mergeWith($command->getVariables());
185 185
         }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     
190 190
     public function getValidationResult() : OperationResult
191 191
     {
192
-        if(isset($this->validationResult))
192
+        if (isset($this->validationResult))
193 193
         {
194 194
             return $this->validationResult;
195 195
         }
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
     {
206 206
         $errors = $this->getErrors();
207 207
         
208
-        foreach($errors as $error)
208
+        foreach ($errors as $error)
209 209
         {
210
-            if($error->getCode() === $code)
210
+            if ($error->getCode() === $code)
211 211
             {
212 212
                 return true;
213 213
             }
Please login to merge, or discard this patch.