Passed
Push — master ( 2147dc...8d3817 )
by Sebastian
03:06 queued 11s
created
src/Mailcode/Parser/Safeguard.php 3 patches
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -53,50 +53,50 @@  discard block
 block discarded – undo
53 53
     const ERROR_EMPTY_DELIMITER = 47803;
54 54
     const ERROR_PLACEHOLDER_NOT_FOUND = 47804;
55 55
     
56
-   /**
57
-    * @var Mailcode_Parser
58
-    */
56
+    /**
57
+     * @var Mailcode_Parser
58
+     */
59 59
     protected $parser;
60 60
     
61
-   /**
62
-    * @var Mailcode_Collection
63
-    */
61
+    /**
62
+     * @var Mailcode_Collection
63
+     */
64 64
     protected $commands;
65 65
     
66
-   /**
67
-    * @var string
68
-    */
66
+    /**
67
+     * @var string
68
+     */
69 69
     protected $originalString;
70 70
     
71
-   /**
72
-    * @var Mailcode_Collection
73
-    */
71
+    /**
72
+     * @var Mailcode_Collection
73
+     */
74 74
     protected $collection;
75 75
     
76
-   /**
77
-    * Counter for the placeholders, global for all placeholders.
78
-    * @var integer
79
-    */
76
+    /**
77
+     * Counter for the placeholders, global for all placeholders.
78
+     * @var integer
79
+     */
80 80
     private static $counter = 0;
81 81
     
82
-   /**
83
-    * @var Mailcode_Parser_Safeguard_Placeholder[]
84
-    */
82
+    /**
83
+     * @var Mailcode_Parser_Safeguard_Placeholder[]
84
+     */
85 85
     protected $placeholders;
86 86
     
87
-   /**
88
-    * @var string
89
-    */
87
+    /**
88
+     * @var string
89
+     */
90 90
     protected $delimiter = '__';
91 91
     
92
-   /**
93
-    * @var string[]|NULL
94
-    */
92
+    /**
93
+     * @var string[]|NULL
94
+     */
95 95
     protected $placeholderStrings;
96 96
     
97
-   /**
98
-    * @var Mailcode_Parser_Safeguard_Formatting|NULL
99
-    */
97
+    /**
98
+     * @var Mailcode_Parser_Safeguard_Formatting|NULL
99
+     */
100 100
     private $formatting = null;
101 101
     
102 102
     public function __construct(Mailcode_Parser $parser, string $subject)
@@ -105,25 +105,25 @@  discard block
 block discarded – undo
105 105
         $this->originalString = $subject;
106 106
     }
107 107
     
108
-   /**
109
-    * Retrieves the string the safeguard was created for.
110
-    * 
111
-    * @return string
112
-    */
108
+    /**
109
+     * Retrieves the string the safeguard was created for.
110
+     * 
111
+     * @return string
112
+     */
113 113
     public function getOriginalString() : string
114 114
     {
115 115
         return $this->originalString;
116 116
     }
117 117
     
118
-   /**
119
-    * Sets the delimiter character sequence used to prepend
120
-    * and append to the placeholders.
121
-    * 
122
-    * The delimiter's default is "__" (two underscores).
123
-    * 
124
-    * @param string $delimiter
125
-    * @return Mailcode_Parser_Safeguard
126
-    */
118
+    /**
119
+     * Sets the delimiter character sequence used to prepend
120
+     * and append to the placeholders.
121
+     * 
122
+     * The delimiter's default is "__" (two underscores).
123
+     * 
124
+     * @param string $delimiter
125
+     * @return Mailcode_Parser_Safeguard
126
+     */
127 127
     public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard
128 128
     {
129 129
         if(empty($delimiter))
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
         return $this->delimiter;
146 146
     }
147 147
     
148
-   /**
149
-    * Retrieves the safe string in which all commands have been replaced
150
-    * by placeholder strings.
151
-    *
152
-    * @return string
153
-    * @throws Mailcode_Exception 
154
-    *
155
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
156
-    */
148
+    /**
149
+     * Retrieves the safe string in which all commands have been replaced
150
+     * by placeholder strings.
151
+     *
152
+     * @return string
153
+     * @throws Mailcode_Exception 
154
+     *
155
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
156
+     */
157 157
     public function makeSafe() : string
158 158
     {
159 159
         $this->requireValidCollection();
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
         return $this->makeSafePartial();
162 162
     }
163 163
     
164
-   /**
165
-    * Like makeSafe(), but allows partial (invalid) commands: use this
166
-    * if the subject string may contain only part of the whole set of
167
-    * commands. 
168
-    * 
169
-    * Example: parsing a text with an opening if statement, without the 
170
-    * matching end statement.
171
-    * 
172
-    * @return string
173
-    */
164
+    /**
165
+     * Like makeSafe(), but allows partial (invalid) commands: use this
166
+     * if the subject string may contain only part of the whole set of
167
+     * commands. 
168
+     * 
169
+     * Example: parsing a text with an opening if statement, without the 
170
+     * matching end statement.
171
+     * 
172
+     * @return string
173
+     */
174 174
     public function makeSafePartial() : string
175 175
     {
176 176
         $placeholders = $this->getPlaceholders();
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
         return $string;
201 201
     }
202 202
     
203
-   /**
204
-    * Creates a formatting handler, which can be used to specify
205
-    * which formattings to use for the commands in the subject string.
206
-    * 
207
-    * @param Mailcode_StringContainer|string $subject
208
-    * @return Mailcode_Parser_Safeguard_Formatting
209
-    */
203
+    /**
204
+     * Creates a formatting handler, which can be used to specify
205
+     * which formattings to use for the commands in the subject string.
206
+     * 
207
+     * @param Mailcode_StringContainer|string $subject
208
+     * @return Mailcode_Parser_Safeguard_Formatting
209
+     */
210 210
     public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting
211 211
     {
212 212
         if(is_string($subject))
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
         return new Mailcode_Parser_Safeguard_Formatting($this, $subject);
218 218
     }
219 219
     
220
-   /**
221
-    * Retrieves all placeholders that have to be added to
222
-    * the subject text.
223
-    * 
224
-    * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
225
-    */
220
+    /**
221
+     * Retrieves all placeholders that have to be added to
222
+     * the subject text.
223
+     * 
224
+     * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
225
+     */
226 226
     public function getPlaceholders()
227 227
     {
228 228
         if(isset($this->placeholders))
@@ -269,16 +269,16 @@  discard block
 block discarded – undo
269 269
         return $formatting->toString();
270 270
     }
271 271
     
272
-   /**
273
-    * Makes the string whole again after transforming or filtering it,
274
-    * by replacing the command placeholders with the original commands.
275
-    *
276
-    * @param string $string
277
-    * @return string
278
-    * @throws Mailcode_Exception
279
-    *
280
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
281
-    */
272
+    /**
273
+     * Makes the string whole again after transforming or filtering it,
274
+     * by replacing the command placeholders with the original commands.
275
+     *
276
+     * @param string $string
277
+     * @return string
278
+     * @throws Mailcode_Exception
279
+     *
280
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
281
+     */
282 282
     public function makeWhole(string $string) : string
283 283
     {
284 284
         return $this->restore(
@@ -288,15 +288,15 @@  discard block
 block discarded – undo
288 288
         );
289 289
     }
290 290
     
291
-   /**
292
-    * Like `makeWhole()`, but ignores missing command placeholders.
293
-    *
294
-    * @param string $string
295
-    * @return string
296
-    * @throws Mailcode_Exception
297
-    *
298
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
299
-    */
291
+    /**
292
+     * Like `makeWhole()`, but ignores missing command placeholders.
293
+     *
294
+     * @param string $string
295
+     * @return string
296
+     * @throws Mailcode_Exception
297
+     *
298
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
299
+     */
300 300
     public function makeWholePartial(string $string) : string
301 301
     {
302 302
         return $this->restore(
@@ -306,19 +306,19 @@  discard block
 block discarded – undo
306 306
         );
307 307
     }
308 308
 
309
-   /**
310
-    * Like `makeWhole()`, but replaces the commands with a syntax
311
-    * highlighted version, meant for human readable texts only.
312
-    * 
313
-    * Note: the commands lose their functionality (They cannot be 
314
-    * parsed from that string again).
315
-    *
316
-    * @param string $string
317
-    * @return string
318
-    * @throws Mailcode_Exception
319
-    *
320
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
321
-    */
309
+    /**
310
+     * Like `makeWhole()`, but replaces the commands with a syntax
311
+     * highlighted version, meant for human readable texts only.
312
+     * 
313
+     * Note: the commands lose their functionality (They cannot be 
314
+     * parsed from that string again).
315
+     *
316
+     * @param string $string
317
+     * @return string
318
+     * @throws Mailcode_Exception
319
+     *
320
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
321
+     */
322 322
     public function makeHighlighted(string $string) : string
323 323
     {
324 324
         return $this->restore(
@@ -328,15 +328,15 @@  discard block
 block discarded – undo
328 328
         );
329 329
     }
330 330
     
331
-   /**
332
-    * Like `makeHighlighted()`, but ignores missing command placeholders.
333
-    * 
334
-    * @param string $string
335
-    * @return string
336
-    * @throws Mailcode_Exception
337
-    *
338
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
339
-    */
331
+    /**
332
+     * Like `makeHighlighted()`, but ignores missing command placeholders.
333
+     * 
334
+     * @param string $string
335
+     * @return string
336
+     * @throws Mailcode_Exception
337
+     *
338
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
339
+     */
340 340
     public function makeHighlightedPartial(string $string) : string
341 341
     {
342 342
         return $this->restore(
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
         );
347 347
     }
348 348
     
349
-   /**
350
-    * Retrieves the commands collection contained in the string.
351
-    * 
352
-    * @return Mailcode_Collection
353
-    */
349
+    /**
350
+     * Retrieves the commands collection contained in the string.
351
+     * 
352
+     * @return Mailcode_Collection
353
+     */
354 354
     public function getCollection() : Mailcode_Collection
355 355
     {
356 356
         if(isset($this->collection))
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
         return $this->getCollection()->isValid();
369 369
     }
370 370
     
371
-   /**
372
-    * @throws Mailcode_Exception
373
-    * 
374
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
375
-    */
371
+    /**
372
+     * @throws Mailcode_Exception
373
+     * 
374
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
375
+     */
376 376
     protected function requireValidCollection() : void
377 377
     {
378 378
         if($this->getCollection()->isValid())
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
         );
392 392
     }
393 393
     
394
-   /**
395
-    * Retrieves a list of all placeholder IDs used in the text.
396
-    * 
397
-    * @return string[]
398
-    */
394
+    /**
395
+     * Retrieves a list of all placeholder IDs used in the text.
396
+     * 
397
+     * @return string[]
398
+     */
399 399
     public function getPlaceholderStrings() : array
400 400
     {
401 401
         if(is_array($this->placeholderStrings))
@@ -422,13 +422,13 @@  discard block
 block discarded – undo
422 422
         return in_array($subject, $ids);
423 423
     }
424 424
     
425
-   /**
426
-    * Retrieves a placeholder instance by its ID.
427
-    * 
428
-    * @param int $id
429
-    * @throws Mailcode_Exception If the placeholder was not found.
430
-    * @return Mailcode_Parser_Safeguard_Placeholder
431
-    */
425
+    /**
426
+     * Retrieves a placeholder instance by its ID.
427
+     * 
428
+     * @param int $id
429
+     * @throws Mailcode_Exception If the placeholder was not found.
430
+     * @return Mailcode_Parser_Safeguard_Placeholder
431
+     */
432 432
     public function getPlaceholderByID(int $id) : Mailcode_Parser_Safeguard_Placeholder
433 433
     {
434 434
         $placeholders = $this->getPlaceholders();
@@ -451,13 +451,13 @@  discard block
 block discarded – undo
451 451
         );
452 452
     }
453 453
     
454
-   /**
455
-    * Retrieves a placeholder instance by its replacement text.
456
-    * 
457
-    * @param string $string
458
-    * @throws Mailcode_Exception
459
-    * @return Mailcode_Parser_Safeguard_Placeholder
460
-    */
454
+    /**
455
+     * Retrieves a placeholder instance by its replacement text.
456
+     * 
457
+     * @param string $string
458
+     * @throws Mailcode_Exception
459
+     * @return Mailcode_Parser_Safeguard_Placeholder
460
+     */
461 461
     public function getPlaceholderByString(string $string) : Mailcode_Parser_Safeguard_Placeholder
462 462
     {
463 463
         $placeholders = $this->getPlaceholders();
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -260,8 +260,7 @@
 block discarded – undo
260 260
         if($highlighted)
261 261
         {
262 262
             $formatting->replaceWithHTMLHighlighting();
263
-        }
264
-        else 
263
+        } else 
265 264
         {
266 265
             $formatting->replaceWithNormalized();
267 266
         }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     */
127 127
     public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard
128 128
     {
129
-        if(empty($delimiter))
129
+        if (empty($delimiter))
130 130
         {
131 131
             throw new Mailcode_Exception(
132 132
                 'Empty delimiter',
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
         $placeholders = $this->getPlaceholders();
177 177
         $string = $this->originalString;
178 178
         
179
-        foreach($placeholders as $placeholder)
179
+        foreach ($placeholders as $placeholder)
180 180
         {
181 181
             $pos = mb_strpos($string, $placeholder->getOriginalText());
182 182
             
183
-            if($pos === false)
183
+            if ($pos === false)
184 184
             {
185 185
                 throw new Mailcode_Exception(
186 186
                     'Placeholder original text not found',
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     */
210 210
     public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting
211 211
     {
212
-        if(is_string($subject))
212
+        if (is_string($subject))
213 213
         {
214 214
             $subject = Mailcode::create()->createString($subject);
215 215
         }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     */
226 226
     public function getPlaceholders()
227 227
     {
228
-        if(isset($this->placeholders))
228
+        if (isset($this->placeholders))
229 229
         {
230 230
             return $this->placeholders;
231 231
         }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
         
235 235
         $cmds = $this->getCollection()->getCommands();
236 236
         
237
-        foreach($cmds as $command)
237
+        foreach ($cmds as $command)
238 238
         {
239 239
             self::$counter++;
240 240
             
@@ -248,21 +248,21 @@  discard block
 block discarded – undo
248 248
         return $this->placeholders;
249 249
     }
250 250
     
251
-    protected function restore(string $string, bool $partial=false, bool $highlighted=false) : string
251
+    protected function restore(string $string, bool $partial = false, bool $highlighted = false) : string
252 252
     {
253
-        if(!$partial)
253
+        if (!$partial)
254 254
         {
255 255
             $this->requireValidCollection();
256 256
         }
257 257
         
258 258
         $formatting = $this->createFormatting($string);
259 259
 
260
-        if($partial)
260
+        if ($partial)
261 261
         {
262 262
             $formatting->makePartial();
263 263
         }
264 264
         
265
-        if($highlighted)
265
+        if ($highlighted)
266 266
         {
267 267
             $formatting->replaceWithHTMLHighlighting();
268 268
         }
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
     */
359 359
     public function getCollection() : Mailcode_Collection
360 360
     {
361
-        if(isset($this->collection))
361
+        if (isset($this->collection))
362 362
         {
363 363
             return $this->collection;
364 364
         }
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
     */
381 381
     protected function requireValidCollection() : void
382 382
     {
383
-        if($this->getCollection()->isValid())
383
+        if ($this->getCollection()->isValid())
384 384
         {
385 385
             return;
386 386
         }
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
     */
404 404
     public function getPlaceholderStrings() : array
405 405
     {
406
-        if(is_array($this->placeholderStrings))
406
+        if (is_array($this->placeholderStrings))
407 407
         {
408 408
             return $this->placeholderStrings;
409 409
         }
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
         
413 413
         $this->placeholderStrings = array();
414 414
         
415
-        foreach($placeholders as $placeholder)
415
+        foreach ($placeholders as $placeholder)
416 416
         {
417 417
             $this->placeholderStrings[] = $placeholder->getReplacementText();
418 418
         }
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
     {
439 439
         $placeholders = $this->getPlaceholders();
440 440
         
441
-        foreach($placeholders as $placeholder)
441
+        foreach ($placeholders as $placeholder)
442 442
         {
443
-            if($placeholder->getID() === $id)
443
+            if ($placeholder->getID() === $id)
444 444
             {
445 445
                 return $placeholder;
446 446
             }
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
     {
468 468
         $placeholders = $this->getPlaceholders();
469 469
         
470
-        foreach($placeholders as $placeholder)
470
+        foreach ($placeholders as $placeholder)
471 471
         {
472
-            if($placeholder->getReplacementText() === $string)
472
+            if ($placeholder->getReplacementText() === $string)
473 473
             {
474 474
                 return $placeholder;
475 475
             }
Please login to merge, or discard this patch.
src/Mailcode/StringContainer.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -26,39 +26,39 @@  discard block
 block discarded – undo
26 26
     const ERROR_INVALID_CALLABLE = 65701;
27 27
     const ERROR_UPDATE_CALLED_DURING_UPDATE_OPERATION = 65702;
28 28
     
29
-   /**
30
-    * @var string
31
-    */
29
+    /**
30
+     * @var string
31
+     */
32 32
     private $subject;
33 33
     
34
-   /**
35
-    * @var integer
36
-    */
34
+    /**
35
+     * @var integer
36
+     */
37 37
     private static $listenerCounter = 0;
38 38
     
39
-   /**
40
-    * @var callable[]
41
-    */
39
+    /**
40
+     * @var callable[]
41
+     */
42 42
     private $listeners = array();
43 43
     
44
-   /**
45
-    * @var boolean
46
-    */
44
+    /**
45
+     * @var boolean
46
+     */
47 47
     private $updating = false;
48 48
     
49
-   /**
50
-    * @var integer
51
-    */
49
+    /**
50
+     * @var integer
51
+     */
52 52
     private static $idCounter = 0;
53 53
     
54
-   /**
55
-    * @var integer
56
-    */
54
+    /**
55
+     * @var integer
56
+     */
57 57
     private $id;
58 58
     
59
-   /**
60
-    * @var integer
61
-    */
59
+    /**
60
+     * @var integer
61
+     */
62 62
     private $length;
63 63
     
64 64
     public function __construct(string $subject)
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
         return $this->id;
76 76
     }
77 77
     
78
-   /**
79
-    * Updates the string with the specified string.
80
-    * Notifies all listeners of the change.
81
-    * 
82
-    * @param string $subject
83
-    * @throws Mailcode_Exception
84
-    * @return bool Whether the string had modifications.
85
-    * 
86
-    * @see Mailcode_StringContainer::ERROR_UPDATE_CALLED_DURING_UPDATE_OPERATION
87
-    */
78
+    /**
79
+     * Updates the string with the specified string.
80
+     * Notifies all listeners of the change.
81
+     * 
82
+     * @param string $subject
83
+     * @throws Mailcode_Exception
84
+     * @return bool Whether the string had modifications.
85
+     * 
86
+     * @see Mailcode_StringContainer::ERROR_UPDATE_CALLED_DURING_UPDATE_OPERATION
87
+     */
88 88
     public function updateString(string $subject) : bool
89 89
     {
90 90
         // avoid triggering an update if there are no changes in the string
@@ -117,27 +117,27 @@  discard block
 block discarded – undo
117 117
         return true;
118 118
     }
119 119
     
120
-   /**
121
-    * Retrieves the stored string.
122
-    * 
123
-    * @return string
124
-    */
120
+    /**
121
+     * Retrieves the stored string.
122
+     * 
123
+     * @return string
124
+     */
125 125
     public function getString() : string
126 126
     {
127 127
         return $this->subject;
128 128
     }
129 129
     
130
-   /**
131
-    * Adds a listener that will be informed every time the string is modified.
132
-    * The callback gets the string container instance as parameter.
133
-    * 
134
-    * @param callable $callback
135
-    * @throws Mailcode_Exception If it is not a valid callable.
136
-    * @return int The listener number, to be able to remove it using `removeListener()`.
137
-    * 
138
-    * @see Mailcode_StringContainer::removeListener()
139
-    * @see Mailcode_StringContainer::ERROR_INVALID_CALLABLE
140
-    */
130
+    /**
131
+     * Adds a listener that will be informed every time the string is modified.
132
+     * The callback gets the string container instance as parameter.
133
+     * 
134
+     * @param callable $callback
135
+     * @throws Mailcode_Exception If it is not a valid callable.
136
+     * @return int The listener number, to be able to remove it using `removeListener()`.
137
+     * 
138
+     * @see Mailcode_StringContainer::removeListener()
139
+     * @see Mailcode_StringContainer::ERROR_INVALID_CALLABLE
140
+     */
141 141
     public function addListener($callback) : int
142 142
     {
143 143
         self::$listenerCounter++;
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
         return $this->length;
165 165
     }
166 166
     
167
-   /**
168
-    * Removes an existing listener by its ID.
169
-    * Has no effect if it does not exist, or has already been removed.
170
-    * 
171
-    * @param int $listenerID
172
-    */
167
+    /**
168
+     * Removes an existing listener by its ID.
169
+     * Has no effect if it does not exist, or has already been removed.
170
+     * 
171
+     * @param int $listenerID
172
+     */
173 173
     public function removeListener(int $listenerID) : void
174 174
     {
175 175
         if(isset($this->listeners[$listenerID]))
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
         }
179 179
     }
180 180
     
181
-   /**
182
-    * Replaces all substrings matching needle with the replacement text.
183
-    *  
184
-    * @param string $needle
185
-    * @param string $replacement
186
-    * @return bool
187
-    */
181
+    /**
182
+     * Replaces all substrings matching needle with the replacement text.
183
+     *  
184
+     * @param string $needle
185
+     * @param string $replacement
186
+     * @return bool
187
+     */
188 188
     public function replaceSubstrings(string $needle, string $replacement) : bool
189 189
     {
190 190
         $string = str_replace($needle, $replacement, $this->subject);
@@ -192,12 +192,12 @@  discard block
 block discarded – undo
192 192
         return $this->updateString($string);
193 193
     }
194 194
 
195
-   /**
196
-    * Get the position of a substring in the string.
197
-    * 
198
-    * @param string $needle
199
-    * @return int|bool The zero-based position, or false if not found.
200
-    */
195
+    /**
196
+     * Get the position of a substring in the string.
197
+     * 
198
+     * @param string $needle
199
+     * @return int|bool The zero-based position, or false if not found.
200
+     */
201 201
     public function getSubstrPosition(string $needle)
202 202
     {
203 203
         return mb_strpos($this->subject, $needle);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
     public function updateString(string $subject) : bool
89 89
     {
90 90
         // avoid triggering an update if there are no changes in the string
91
-        if($subject === $this->subject)
91
+        if ($subject === $this->subject)
92 92
         {
93 93
             return false;
94 94
         }
95 95
         
96
-        if($this->updating)
96
+        if ($this->updating)
97 97
         {
98 98
             throw new Mailcode_Exception(
99 99
                 'Cannot modify subject string during update',
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         $this->subject = $subject;
108 108
         $this->length = mb_strlen($this->subject);
109 109
         
110
-        foreach($this->listeners as $listener)
110
+        foreach ($this->listeners as $listener)
111 111
         {
112 112
             $listener($this);
113 113
         }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
     {
143 143
         self::$listenerCounter++;
144 144
         
145
-        if(!is_callable($callback))
145
+        if (!is_callable($callback))
146 146
         {
147 147
             throw new Mailcode_Exception(
148 148
                 'Not a valid callable',
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     */
173 173
     public function removeListener(int $listenerID) : void
174 174
     {
175
-        if(isset($this->listeners[$listenerID]))
175
+        if (isset($this->listeners[$listenerID]))
176 176
         {
177 177
             unset($this->listeners[$listenerID]);
178 178
         }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         return mb_strpos($this->subject, $needle);
204 204
     }
205 205
     
206
-    public function getSubstr(int $start, ?int $length=null) : string
206
+    public function getSubstr(int $start, ?int $length = null) : string
207 207
     {
208 208
         return mb_substr($this->subject, $start, $length);
209 209
     }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Location.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -24,34 +24,34 @@  discard block
 block discarded – undo
24 24
 {
25 25
     const ERROR_PLACEHOLDER_NOT_FOUND = 66001;
26 26
     
27
-   /**
28
-    * @var Mailcode_Parser_Safeguard_Formatter
29
-    */
27
+    /**
28
+     * @var Mailcode_Parser_Safeguard_Formatter
29
+     */
30 30
     protected $formatter;
31 31
     
32
-   /**
33
-    * @var string
34
-    */
32
+    /**
33
+     * @var string
34
+     */
35 35
     protected $append = '';
36 36
 
37
-   /**
38
-    * @var string
39
-    */
37
+    /**
38
+     * @var string
39
+     */
40 40
     protected $prepend = '';
41 41
     
42
-   /**
43
-    * @var Mailcode_Parser_Safeguard_Placeholder
44
-    */
42
+    /**
43
+     * @var Mailcode_Parser_Safeguard_Placeholder
44
+     */
45 45
     protected $placeholder;
46 46
     
47
-   /**
48
-    * @var Mailcode_StringContainer
49
-    */
47
+    /**
48
+     * @var Mailcode_StringContainer
49
+     */
50 50
     protected $subject;
51 51
     
52
-   /**
53
-    * @var string[]
54
-    */
52
+    /**
53
+     * @var string[]
54
+     */
55 55
     protected $log = array();
56 56
     
57 57
     public function __construct(Mailcode_Parser_Safeguard_Formatter $formatter, Mailcode_Parser_Safeguard_Placeholder $placeholder)
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
     
68 68
     abstract public function requiresAdjustment() : bool;
69 69
     
70
-   /**
71
-    * @return int|boolean
72
-    */
70
+    /**
71
+     * @return int|boolean
72
+     */
73 73
     public function getStartPosition()
74 74
     {
75 75
         return $this->subject->getSubstrPosition($this->placeholder->getReplacementText());
76 76
     }
77 77
     
78
-   /**
79
-    * Checks whether the specified position within the string
80
-    * is within another command's placeholder (excluding this
81
-    * location's placeholder).
82
-    * 
83
-    * @param int $position
84
-    * @return bool
85
-    */
78
+    /**
79
+     * Checks whether the specified position within the string
80
+     * is within another command's placeholder (excluding this
81
+     * location's placeholder).
82
+     * 
83
+     * @param int $position
84
+     * @return bool
85
+     */
86 86
     public function isWithinCommand(int $position) : bool
87 87
     {
88 88
         $placeholders = $this->formatter->getSafeguard()->getPlaceholders();
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
         return false;
115 115
     }
116 116
     
117
-   /**
118
-    * @return int|boolean
119
-    */
117
+    /**
118
+     * @return int|boolean
119
+     */
120 120
     public function getEndPosition()
121 121
     {
122 122
         $start = $this->getStartPosition();
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
         return $this->placeholder;
140 140
     }
141 141
     
142
-   /**
143
-    * Replaces the placeholder with the specified replacement text.
144
-    * 
145
-    * @param string $replacementText
146
-    * @throws Mailcode_Exception
147
-    * 
148
-    * @see Mailcode_Parser_Safeguard_Formatter_Location::ERROR_PLACEHOLDER_NOT_FOUND
149
-    */
142
+    /**
143
+     * Replaces the placeholder with the specified replacement text.
144
+     * 
145
+     * @param string $replacementText
146
+     * @throws Mailcode_Exception
147
+     * 
148
+     * @see Mailcode_Parser_Safeguard_Formatter_Location::ERROR_PLACEHOLDER_NOT_FOUND
149
+     */
150 150
     public function replaceWith(string $replacementText) : void
151 151
     {
152 152
         $needle = $this->placeholder->getReplacementText();
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
         );
190 190
     }
191 191
     
192
-   /**
193
-    * Retrieves the location's log messages, if any.
194
-    * @return string[]
195
-    */
192
+    /**
193
+     * Retrieves the location's log messages, if any.
194
+     * @return string[]
195
+     */
196 196
     public function getLog() : array
197 197
     {
198 198
         return $this->log;
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -89,23 +89,23 @@  discard block
 block discarded – undo
89 89
         
90 90
         $placeholderID = $this->placeholder->getID();
91 91
         
92
-        foreach($placeholders as $placeholder)
92
+        foreach ($placeholders as $placeholder)
93 93
         {
94
-            if($placeholder->getID() === $placeholderID)
94
+            if ($placeholder->getID() === $placeholderID)
95 95
             {
96 96
                 continue;
97 97
             }
98 98
             
99 99
             $start = $this->subject->getSubstrPosition($placeholder->getReplacementText());
100 100
             
101
-            if($start === false)
101
+            if ($start === false)
102 102
             {
103 103
                 continue;
104 104
             }
105 105
             
106 106
             $end = $start + $placeholder->getReplacementLength();
107 107
             
108
-            if($position >= $start && $position <= $end)
108
+            if ($position >= $start && $position <= $end)
109 109
             {
110 110
                 return true;
111 111
             }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     {
122 122
         $start = $this->getStartPosition();
123 123
         
124
-        if($start !== false)
124
+        if ($start !== false)
125 125
         {
126 126
             return $start + $this->placeholder->getReplacementLength();
127 127
         }
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
     {
152 152
         $needle = $this->placeholder->getReplacementText();
153 153
         
154
-        if($this->subject->replaceSubstrings($needle, $replacementText))
154
+        if ($this->subject->replaceSubstrings($needle, $replacementText))
155 155
         {
156 156
             return;
157 157
         }
158 158
         
159 159
         // Complain about missing placeholders only if we
160 160
         // are not in partial mode.
161
-        if(!$this->formatter->getFormatting()->isPartial())
161
+        if (!$this->formatter->getFormatting()->isPartial())
162 162
         {
163 163
             throw new Mailcode_Exception(
164 164
                 'Could not find the placeholder to replace',
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     
174 174
     public function format() : void
175 175
     {
176
-        if($this->requiresAdjustment() && (!empty($this->prepend) || !empty($this->append)))
176
+        if ($this->requiresAdjustment() && (!empty($this->prepend) || !empty($this->append)))
177 177
         {
178 178
             $this->replaceWith(sprintf(
179 179
                 '%s%s%s',
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
 {
28 28
     const ERROR_INVALID_LOCATION_INSTANCE = 65601;
29 29
     
30
-   /**
31
-    * @var Mailcode_Parser_Safeguard_Formatting
32
-    */
30
+    /**
31
+     * @var Mailcode_Parser_Safeguard_Formatting
32
+     */
33 33
     protected $formatting;
34 34
     
35
-   /**
36
-    * @var Mailcode_StringContainer
37
-    */
35
+    /**
36
+     * @var Mailcode_StringContainer
37
+     */
38 38
     protected $subject;
39 39
     
40
-   /**
41
-    * @var string[]
42
-    */
40
+    /**
41
+     * @var string[]
42
+     */
43 43
     protected $log = array();
44 44
     
45 45
     public function __construct(Mailcode_Parser_Safeguard_Formatting $formatting)
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
         );
94 94
     }
95 95
     
96
-   /**
97
-    * Retrieves all formatter-specific placeholder locations 
98
-    * in the subject string.
99
-    * 
100
-    * @return Mailcode_Parser_Safeguard_Formatter_Location[]
101
-    */
96
+    /**
97
+     * Retrieves all formatter-specific placeholder locations 
98
+     * in the subject string.
99
+     * 
100
+     * @return Mailcode_Parser_Safeguard_Formatter_Location[]
101
+     */
102 102
     protected function resolveLocations() : array
103 103
     {
104 104
         $placeholders = $this->formatting->getSafeguard()->getPlaceholders();
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
         return $result;
114 114
     }
115 115
     
116
-   /**
117
-    * Resolves the newline character used in the string.
118
-    * 
119
-    * @param string $subject
120
-    * @return string
121
-    */
116
+    /**
117
+     * Resolves the newline character used in the string.
118
+     * 
119
+     * @param string $subject
120
+     * @return string
121
+     */
122 122
     protected function resolveNewlineChar(string $subject) : string
123 123
     {
124 124
         $eol = ConvertHelper::detectEOLCharacter($subject);
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
         );
151 151
     }
152 152
  
153
-   /**
154
-    * @return string[]
155
-    */
153
+    /**
154
+     * @return string[]
155
+     */
156 156
     public function getLog() : array
157 157
     {
158 158
         return $this->log;
Please login to merge, or discard this 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/Traits/Formatting/HTMLHighlighting.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -23,21 +23,21 @@  discard block
 block discarded – undo
23 23
  */
24 24
 trait Mailcode_Traits_Formatting_HTMLHighlighting
25 25
 {
26
-   /**
27
-    * @var string[]
28
-    */
26
+    /**
27
+     * @var string[]
28
+     */
29 29
     private $excludeTags = array(
30 30
         'style', // NOTE: style tags are excluded natively on the parser level.
31 31
         'script'
32 32
     );
33 33
     
34
-   /**
35
-    * Adds an HTML tag name to the list of tags within which
36
-    * commands may not be highlighted.
37
-    *
38
-    * @param string $tagName Case insensitive.
39
-    * @return $this
40
-    */
34
+    /**
35
+     * Adds an HTML tag name to the list of tags within which
36
+     * commands may not be highlighted.
37
+     *
38
+     * @param string $tagName Case insensitive.
39
+     * @return $this
40
+     */
41 41
     public function excludeTag(string $tagName)
42 42
     {
43 43
         $tagName = strtolower($tagName);
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
         return $this;
51 51
     }
52 52
     
53
-   /**
54
-    * Adds several exluded tag names at once.
55
-    *
56
-    * @param string[] $tagNames
57
-    * @return $this
58
-    */
53
+    /**
54
+     * Adds several exluded tag names at once.
55
+     *
56
+     * @param string[] $tagNames
57
+     * @return $this
58
+     */
59 59
     public function excludeTags(array $tagNames)
60 60
     {
61 61
         foreach($tagNames as $tagName)
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
         return $this;
67 67
     }
68 68
     
69
-   /**
70
-    * Whether the specified tag name is in the exlusion list.
71
-    *
72
-    * @param string $tagName
73
-    * @return bool
74
-    */
69
+    /**
70
+     * Whether the specified tag name is in the exlusion list.
71
+     *
72
+     * @param string $tagName
73
+     * @return bool
74
+     */
75 75
     public function isTagExcluded(string $tagName) : bool
76 76
     {
77 77
         $tagName = strtolower($tagName);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     {
43 43
         $tagName = strtolower($tagName);
44 44
         
45
-        if(!in_array($tagName, $this->excludeTags))
45
+        if (!in_array($tagName, $this->excludeTags))
46 46
         {
47 47
             $this->excludeTags[] = $tagName;
48 48
         }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     */
59 59
     public function excludeTags(array $tagNames)
60 60
     {
61
-        foreach($tagNames as $tagName)
61
+        foreach ($tagNames as $tagName)
62 62
         {
63 63
             $this->excludeTag((string)$tagName);
64 64
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowVariable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
     {
72 72
         $tokens = $this->params->getInfo()->getTokens();
73 73
 
74
-        if(count($tokens) > 1)
74
+        if (count($tokens) > 1)
75 75
         {
76 76
             $this->validationResult->makeError(
77 77
                 t('Unknown parameters found:').' '.
Please login to merge, or discard this patch.
src/Mailcode/Collection.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         
100 100
         $errors = $this->errors;
101 101
         
102
-        if(!$result->isValid())
102
+        if (!$result->isValid())
103 103
         {
104 104
             $errors[] = new Mailcode_Collection_Error_Message(
105 105
                 '',
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     {
116 116
         $errors = $this->getErrors();
117 117
         
118
-        if(!empty($errors))
118
+        if (!empty($errors))
119 119
         {
120 120
             return array_shift($errors);
121 121
         }
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
     {
158 158
         $hashes = array();
159 159
         
160
-        foreach($this->commands as $command)
160
+        foreach ($this->commands as $command)
161 161
         {
162 162
             $hash = $command->getHash();
163 163
             
164
-            if(!isset($hashes[$hash]))
164
+            if (!isset($hashes[$hash]))
165 165
             {
166 166
                 $hashes[$hash] = $command;
167 167
             }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
     */
179 179
     public function addCommands(array $commands) : Mailcode_Collection
180 180
     {
181
-        foreach($commands as $command)
181
+        foreach ($commands as $command)
182 182
         {
183 183
             $this->addCommand($command);
184 184
         }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     {
198 198
         $collection = new Mailcode_Variables_Collection_Regular();
199 199
         
200
-        foreach($this->commands as $command)
200
+        foreach ($this->commands as $command)
201 201
         {
202 202
             $collection->mergeWith($command->getVariables());
203 203
         }
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     
208 208
     public function getValidationResult() : OperationResult
209 209
     {
210
-        if($this->validationResult instanceof OperationResult)
210
+        if ($this->validationResult instanceof OperationResult)
211 211
         {
212 212
             return $this->validationResult;
213 213
         }
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
     {
224 224
         $errors = $this->getErrors();
225 225
         
226
-        foreach($errors as $error)
226
+        foreach ($errors as $error)
227 227
         {
228
-            if($error->getCode() === $code)
228
+            if ($error->getCode() === $code)
229 229
             {
230 230
                 return true;
231 231
             }
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
     {
263 263
         $result = array();
264 264
 
265
-        foreach($this->commands as $command)
265
+        foreach ($this->commands as $command)
266 266
         {
267
-            if($command instanceof $className)
267
+            if ($command instanceof $className)
268 268
             {
269 269
                 $result[] = $command;
270 270
             }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     {
278 278
         $commands = $this->getCommands();
279 279
         
280
-        if(!empty($commands))
280
+        if (!empty($commands))
281 281
         {
282 282
             return array_shift($commands);
283 283
         }
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 {
25 25
     const ERROR_CANNOT_RETRIEVE_FIRST_ERROR = 52301;
26 26
     
27
-   /**
28
-    * @var Mailcode_Commands_Command[]
29
-    */
27
+    /**
28
+     * @var Mailcode_Commands_Command[]
29
+     */
30 30
     protected $commands = array();
31 31
     
32 32
     /**
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
      */
35 35
     protected $errors = array();
36 36
     
37
-   /**
38
-    * @var OperationResult|NULL
39
-    */
37
+    /**
38
+     * @var OperationResult|NULL
39
+     */
40 40
     protected $validationResult;
41 41
     
42
-   /**
43
-    * Adds a command to the collection.
44
-    * 
45
-    * @param Mailcode_Commands_Command $command
46
-    * @return Mailcode_Collection
47
-    */
42
+    /**
43
+     * Adds a command to the collection.
44
+     * 
45
+     * @param Mailcode_Commands_Command $command
46
+     * @return Mailcode_Collection
47
+     */
48 48
     public function addCommand(Mailcode_Commands_Command $command) : Mailcode_Collection
49 49
     {
50 50
         $this->commands[] = $command;
@@ -56,21 +56,21 @@  discard block
 block discarded – undo
56 56
         return $this;
57 57
     }
58 58
     
59
-   /**
60
-    * Whether there are any commands in the collection.
61
-    * 
62
-    * @return bool
63
-    */
59
+    /**
60
+     * Whether there are any commands in the collection.
61
+     * 
62
+     * @return bool
63
+     */
64 64
     public function hasCommands() : bool
65 65
     {
66 66
         return !empty($this->commands);
67 67
     }
68 68
     
69
-   /**
70
-    * Counts the amount of commands in the collection.
71
-    * 
72
-    * @return int
73
-    */
69
+    /**
70
+     * Counts the amount of commands in the collection.
71
+     * 
72
+     * @return int
73
+     */
74 74
     public function countCommands() : int
75 75
     {
76 76
         return count($this->commands);
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
         $this->errors[] = new Mailcode_Collection_Error_Command($command);
91 91
     }
92 92
     
93
-   /**
94
-    * @return Mailcode_Collection_Error[]
95
-    */
93
+    /**
94
+     * @return Mailcode_Collection_Error[]
95
+     */
96 96
     public function getErrors()
97 97
     {
98 98
         $result = $this->getValidationResult();
@@ -134,25 +134,25 @@  discard block
 block discarded – undo
134 134
         return empty($errors);
135 135
     }
136 136
     
137
-   /**
138
-    * Retrieves all commands that were detected, in the exact order
139
-    * they were found.
140
-    * 
141
-    * @return \Mailcode\Mailcode_Commands_Command[]
142
-    */
137
+    /**
138
+     * Retrieves all commands that were detected, in the exact order
139
+     * they were found.
140
+     * 
141
+     * @return \Mailcode\Mailcode_Commands_Command[]
142
+     */
143 143
     public function getCommands()
144 144
     {
145
-       return $this->commands;
145
+        return $this->commands;
146 146
     }
147 147
     
148
-   /**
149
-    * Retrieves all unique commands by their matched
150
-    * string hash: this ensures only commands that were
151
-    * written the exact same way (including spacing)
152
-    * are returned.
153
-    * 
154
-    * @return \Mailcode\Mailcode_Commands_Command[]
155
-    */
148
+    /**
149
+     * Retrieves all unique commands by their matched
150
+     * string hash: this ensures only commands that were
151
+     * written the exact same way (including spacing)
152
+     * are returned.
153
+     * 
154
+     * @return \Mailcode\Mailcode_Commands_Command[]
155
+     */
156 156
     public function getGroupedByHash()
157 157
     {
158 158
         $hashes = array();
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
         return array_values($hashes);
171 171
     }
172 172
 
173
-   /**
174
-    * Adds several commands at once.
175
-    * 
176
-    * @param Mailcode_Commands_Command[] $commands
177
-    * @return Mailcode_Collection
178
-    */
173
+    /**
174
+     * Adds several commands at once.
175
+     * 
176
+     * @param Mailcode_Commands_Command[] $commands
177
+     * @return Mailcode_Collection
178
+     */
179 179
     public function addCommands(array $commands) : Mailcode_Collection
180 180
     {
181 181
         foreach($commands as $command)
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
         return false;
235 235
     }
236 236
     
237
-   /**
238
-    * Retrieves only show variable commands in the collection, if any.
239
-    * 
240
-    * @return Mailcode_Commands_Command_ShowVariable[]
241
-    */
237
+    /**
238
+     * Retrieves only show variable commands in the collection, if any.
239
+     * 
240
+     * @return Mailcode_Commands_Command_ShowVariable[]
241
+     */
242 242
     public function getShowVariableCommands()
243 243
     {
244 244
         return $this->getCommandsByClass(Mailcode_Commands_Command_ShowVariable::class);
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
         return $this->getCommandsByClass(Mailcode_Commands_Command_For::class);
253 253
     }
254 254
 
255
-   /**
256
-    * Retrieves only show date commands in the collection, if any.
257
-    *
258
-    * @return Mailcode_Commands_Command_ShowDate[]
259
-    */
255
+    /**
256
+     * Retrieves only show date commands in the collection, if any.
257
+     *
258
+     * @return Mailcode_Commands_Command_ShowDate[]
259
+     */
260 260
     public function getShowDateCommands() : array
261 261
     {
262 262
         return $this->getCommandsByClass(Mailcode_Commands_Command_ShowDate::class);
Please login to merge, or discard this patch.
src/Mailcode/Translator/Syntax/ApacheVelocity/ShowDate.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $internalFormat = $command->getTranslationParam('internal_format');
54 54
 
55
-        if(empty($internalFormat))
55
+        if (empty($internalFormat))
56 56
         {
57 57
             $internalFormat = self::DEFAULT_INTERNAL_FORMAT;
58 58
         }
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
         $chars = ConvertHelper::string2array($formatString);
71 71
         $result = array();
72 72
         
73
-        foreach($chars as $char)
73
+        foreach ($chars as $char)
74 74
         {
75
-            if(!isset($this->charTable[$char]))
75
+            if (!isset($this->charTable[$char]))
76 76
             {
77 77
                 throw new Mailcode_Translator_Exception(
78 78
                     'Unknown date format string character',
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@
 block discarded – undo
24 24
 {
25 25
     const ERROR_UNKNOWN_DATE_FORMAT_CHARACTER = 55501;
26 26
 
27
-   /**
28
-    * The date format used in the date variable. This is used to convert
29
-    * the native date to the format specified in the variable command.
30
-    */
27
+    /**
28
+     * The date format used in the date variable. This is used to convert
29
+     * the native date to the format specified in the variable command.
30
+     */
31 31
     const DEFAULT_INTERNAL_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
32 32
 
33
-   /**
34
-    * @var string[]string
35
-    */
33
+    /**
34
+     * @var string[]string
35
+     */
36 36
     private $charTable = array(
37 37
         'd' => 'dd',
38 38
         'j' => 'd',
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -32,44 +32,44 @@  discard block
 block discarded – undo
32 32
     const VALIDATION_UNKNOWN_COMMAND_NAME = 48304;
33 33
     const VALIDATION_INVALID_PARAMS_STATEMENT = 48305;
34 34
 
35
-   /**
36
-    * @var string
37
-    */
35
+    /**
36
+     * @var string
37
+     */
38 38
     protected $type = '';
39 39
 
40
-   /**
41
-    * @var string
42
-    */
40
+    /**
41
+     * @var string
42
+     */
43 43
     protected $paramsString = '';
44 44
     
45
-   /**
46
-    * @var string
47
-    */
45
+    /**
46
+     * @var string
47
+     */
48 48
     protected $matchedText = '';
49 49
 
50
-   /**
51
-    * @var string
52
-    */
50
+    /**
51
+     * @var string
52
+     */
53 53
     protected $hash = '';
54 54
     
55
-   /**
56
-    * @var \AppUtils\OperationResult
57
-    */
55
+    /**
56
+     * @var \AppUtils\OperationResult
57
+     */
58 58
     protected $validationResult = null;
59 59
     
60
-   /**
61
-    * @var \Mailcode\Mailcode
62
-    */
60
+    /**
61
+     * @var \Mailcode\Mailcode
62
+     */
63 63
     protected $mailcode;
64 64
     
65
-   /**
66
-    * @var \Mailcode\Mailcode_Parser_Statement
67
-    */
65
+    /**
66
+     * @var \Mailcode\Mailcode_Parser_Statement
67
+     */
68 68
     protected $params;
69 69
 
70
-   /**
71
-    * @var string[] 
72
-    */
70
+    /**
71
+     * @var string[] 
72
+     */
73 73
     protected $validations = array(
74 74
         'params_empty',
75 75
         'params_keywords',
@@ -78,24 +78,24 @@  discard block
 block discarded – undo
78 78
         'type_unsupported'
79 79
     );
80 80
     
81
-   /**
82
-    * @var string
83
-    */
81
+    /**
82
+     * @var string
83
+     */
84 84
     protected $comment = '';
85 85
     
86
-   /**
87
-    * @var Mailcode_Commands_LogicKeywords|NULL
88
-    */
86
+    /**
87
+     * @var Mailcode_Commands_LogicKeywords|NULL
88
+     */
89 89
     protected $logicKeywords;
90 90
     
91
-   /**
92
-    * @var Mailcode_Parser_Statement_Validator
93
-    */
91
+    /**
92
+     * @var Mailcode_Parser_Statement_Validator
93
+     */
94 94
     protected $validator;
95 95
     
96
-   /**
97
-    * @var boolean
98
-    */
96
+    /**
97
+     * @var boolean
98
+     */
99 99
     private $validated = false;
100 100
 
101 101
     /**
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
         
126 126
     }
127 127
 
128
-   /**
129
-    * Sets the command's parent opening command, if any.
130
-    * NOTE: This is set automatically by the parser, and
131
-    * should not be called manually.
132
-    *
133
-    * @param Mailcode_Commands_Command $command
134
-    */
128
+    /**
129
+     * Sets the command's parent opening command, if any.
130
+     * NOTE: This is set automatically by the parser, and
131
+     * should not be called manually.
132
+     *
133
+     * @param Mailcode_Commands_Command $command
134
+     */
135 135
     public function setParent(Mailcode_Commands_Command $command) : void
136 136
     {
137 137
         $this->parent = $command;
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
         return $this->parent;
148 148
     }
149 149
     
150
-   /**
151
-    * @return string The ID of the command = the name of the command class file.
152
-    */
150
+    /**
151
+     * @return string The ID of the command = the name of the command class file.
152
+     */
153 153
     public function getID() : string
154 154
     {
155 155
         // account for commands with types: If_Variable should still return If.
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
         return array_shift($tokens);
159 159
     }
160 160
     
161
-   /**
162
-    * Sets an optional comment that is not used anywhere, but
163
-    * can be used by the application to track why a command is
164
-    * used somewhere. 
165
-    * 
166
-    * @param string $comment
167
-    * @return Mailcode_Commands_Command
168
-    */
161
+    /**
162
+     * Sets an optional comment that is not used anywhere, but
163
+     * can be used by the application to track why a command is
164
+     * used somewhere. 
165
+     * 
166
+     * @param string $comment
167
+     * @return Mailcode_Commands_Command
168
+     */
169 169
     public function setComment(string $comment) : Mailcode_Commands_Command
170 170
     {
171 171
         $this->comment = $comment;
@@ -173,34 +173,34 @@  discard block
 block discarded – undo
173 173
         return $this;
174 174
     }
175 175
     
176
-   /**
177
-    * Retrieves the previously set comment, if any.
178
-    * 
179
-    * @return string
180
-    */
176
+    /**
177
+     * Retrieves the previously set comment, if any.
178
+     * 
179
+     * @return string
180
+     */
181 181
     public function getComment() : string
182 182
     {
183 183
         return $this->comment;
184 184
     }
185 185
     
186
-   /**
187
-    * Checks whether this is a dummy command, which is only
188
-    * used to access information on the command type. It cannot
189
-    * be used as an actual live command.
190
-    * 
191
-    * @return bool
192
-    */
186
+    /**
187
+     * Checks whether this is a dummy command, which is only
188
+     * used to access information on the command type. It cannot
189
+     * be used as an actual live command.
190
+     * 
191
+     * @return bool
192
+     */
193 193
     public function isDummy() : bool
194 194
     {
195 195
         return $this->type === '__dummy';
196 196
     }
197 197
     
198
-   /**
199
-    * Retrieves a hash of the actual matched command string,
200
-    * which is used in collections to detect duplicate commands.
201
-    * 
202
-    * @return string
203
-    */
198
+    /**
199
+     * Retrieves a hash of the actual matched command string,
200
+     * which is used in collections to detect duplicate commands.
201
+     * 
202
+     * @return string
203
+     */
204 204
     public function getHash() : string
205 205
     {
206 206
         $this->requireNonDummy();
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
         return $this->validationResult->isValid();
295 295
     }
296 296
     
297
-   /**
298
-    * @return string[]
299
-    */
297
+    /**
298
+     * @return string[]
299
+     */
300 300
     abstract protected function getValidations() : array;
301 301
     
302 302
     protected function validateSyntax_params_empty() : void
@@ -455,12 +455,12 @@  discard block
 block discarded – undo
455 455
     
456 456
     abstract public function supportsType() : bool;
457 457
     
458
-   /**
459
-    * Whether the command allows using logic keywords like "and:" or "or:"
460
-    * in the command parameters.
461
-    * 
462
-    * @return bool
463
-    */
458
+    /**
459
+     * Whether the command allows using logic keywords like "and:" or "or:"
460
+     * in the command parameters.
461
+     * 
462
+     * @return bool
463
+     */
464 464
     abstract public function supportsLogicKeywords() : bool;
465 465
     
466 466
     abstract public function generatesContent() : bool;
@@ -506,22 +506,22 @@  discard block
 block discarded – undo
506 506
         return $normalizer->normalize();
507 507
     }
508 508
     
509
-   /**
510
-    * Retrieves the names of all the command's supported types: the part
511
-    * between the command name and the colon. Example: {command type: params}.
512
-    * 
513
-    * @return string[]
514
-    */
509
+    /**
510
+     * Retrieves the names of all the command's supported types: the part
511
+     * between the command name and the colon. Example: {command type: params}.
512
+     * 
513
+     * @return string[]
514
+     */
515 515
     public function getSupportedTypes() : array
516 516
     {
517 517
         return array();
518 518
     }
519 519
     
520
-   /**
521
-    * Retrieves all variable names used in the command.
522
-    * 
523
-    * @return Mailcode_Variables_Collection_Regular
524
-    */
520
+    /**
521
+     * Retrieves all variable names used in the command.
522
+     * 
523
+     * @return Mailcode_Variables_Collection_Regular
524
+     */
525 525
     public function getVariables() : Mailcode_Variables_Collection_Regular
526 526
     {
527 527
         return Mailcode::create()->findVariables($this->paramsString);
@@ -546,26 +546,26 @@  discard block
 block discarded – undo
546 546
         );
547 547
     }
548 548
 
549
-   /**
550
-    * Sets a parameter for the translation backend. The backend can use
551
-    * these to allow command-specific configurations.
552
-    *
553
-    * @param string $name
554
-    * @param mixed $value
555
-    * @return $this
556
-    */
549
+    /**
550
+     * Sets a parameter for the translation backend. The backend can use
551
+     * these to allow command-specific configurations.
552
+     *
553
+     * @param string $name
554
+     * @param mixed $value
555
+     * @return $this
556
+     */
557 557
     public function setTranslationParam(string $name, $value)
558 558
     {
559 559
         $this->translationParams[$name] = $value;
560 560
         return $this;
561 561
     }
562 562
 
563
-   /**
564
-    * Retrieves a previously set translation parameter.
565
-    *
566
-    * @param string $name
567
-    * @return mixed
568
-    */
563
+    /**
564
+     * Retrieves a previously set translation parameter.
565
+     *
566
+     * @param string $name
567
+     * @return mixed
568
+     */
569 569
     public function getTranslationParam(string $name)
570 570
     {
571 571
         if(isset($this->translationParams[$name]))
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     protected $parent = null;
111 111
 
112
-    public function __construct(string $type='', string $paramsString='', string $matchedText='')
112
+    public function __construct(string $type = '', string $paramsString = '', string $matchedText = '')
113 113
     {
114 114
         $this->type = $type;
115 115
         $this->paramsString = html_entity_decode($paramsString);
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     {
206 206
         $this->requireNonDummy();
207 207
         
208
-        if($this->hash === '') {
208
+        if ($this->hash === '') {
209 209
             $this->hash = md5($this->matchedText);
210 210
         }
211 211
         
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
     
215 215
     protected function requireNonDummy() : void
216 216
     {
217
-        if(!$this->isDummy())
217
+        if (!$this->isDummy())
218 218
         {
219 219
             return;
220 220
         }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     
234 234
     protected function validate() : \AppUtils\OperationResult
235 235
     {
236
-        if(!$this->validated)
236
+        if (!$this->validated)
237 237
         {
238 238
             $this->requireNonDummy();
239 239
             $this->validateSyntax();
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
     
247 247
     public function getValidationResult() :  \AppUtils\OperationResult
248 248
     {
249
-        if(isset($this->validationResult)) 
249
+        if (isset($this->validationResult)) 
250 250
         {
251 251
             return $this->validationResult;
252 252
         }
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
     {
263 263
         $validations = array_merge($this->validations, $this->getValidations());
264 264
         
265
-        foreach($validations as $validation)
265
+        foreach ($validations as $validation)
266 266
         {
267 267
             // break off at the first validation issue
268
-            if(!$this->validateSyntaxMethod($validation))
268
+            if (!$this->validateSyntaxMethod($validation))
269 269
             {
270 270
                 return;
271 271
             }
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
     {
277 277
         $method = 'validateSyntax_'.$validation;
278 278
         
279
-        if(!method_exists($this, $method))
279
+        if (!method_exists($this, $method))
280 280
         {
281 281
             throw new Mailcode_Exception(
282 282
                 'Missing validation method ['.$validation.']',
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
     
302 302
     protected function validateSyntax_params_empty() : void
303 303
     {
304
-        if(!$this->requiresParameters())
304
+        if (!$this->requiresParameters())
305 305
         {
306 306
             return;
307 307
         }
308 308
         
309
-        if(empty($this->paramsString))
309
+        if (empty($this->paramsString))
310 310
         {
311 311
             $this->validationResult->makeError(
312 312
                 t('Parameters have to be specified.'),
@@ -318,14 +318,14 @@  discard block
 block discarded – undo
318 318
     
319 319
     protected function validateSyntax_params_keywords() : void
320 320
     {
321
-        if(!$this->supportsLogicKeywords())
321
+        if (!$this->supportsLogicKeywords())
322 322
         {
323 323
             return;
324 324
         }
325 325
         
326 326
         $this->logicKeywords = new Mailcode_Commands_LogicKeywords($this, $this->paramsString);
327 327
         
328
-        if(!$this->logicKeywords->isValid())
328
+        if (!$this->logicKeywords->isValid())
329 329
         {
330 330
             $this->validationResult->makeError(
331 331
                 t('Invalid parameters:').' '.$this->logicKeywords->getErrorMessage(),
@@ -340,14 +340,14 @@  discard block
 block discarded – undo
340 340
     
341 341
     protected function validateSyntax_params_parse() : void
342 342
     {
343
-        if(!$this->requiresParameters())
343
+        if (!$this->requiresParameters())
344 344
         {
345 345
             return;
346 346
         }
347 347
         
348 348
         $this->params = $this->mailcode->getParser()->createStatement($this->paramsString);
349 349
         
350
-        if(!$this->params->isValid())
350
+        if (!$this->params->isValid())
351 351
         {
352 352
             $error = $this->params->getValidationResult();
353 353
             
@@ -364,14 +364,14 @@  discard block
 block discarded – undo
364 364
     
365 365
     protected function validateSyntax_type_supported() : void
366 366
     {
367
-        if(!$this->supportsType() || empty($this->type))
367
+        if (!$this->supportsType() || empty($this->type))
368 368
         {
369 369
             return;
370 370
         }
371 371
         
372 372
         $types = $this->getSupportedTypes();
373 373
 
374
-        if(!in_array($this->type, $types))
374
+        if (!in_array($this->type, $types))
375 375
         {
376 376
             $this->validationResult->makeError(
377 377
                 t('The command addon %1$s is not supported.', $this->type).' '.
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
     
386 386
     protected function validateSyntax_type_unsupported() : void
387 387
     {
388
-        if($this->supportsType() || empty($this->type))
388
+        if ($this->supportsType() || empty($this->type))
389 389
         {
390 390
             return;
391 391
         }
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
     
404 404
     public function getType() : string
405 405
     {
406
-        if($this->supportsType())
406
+        if ($this->supportsType())
407 407
         {
408 408
             return $this->type;
409 409
         }
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
     
424 424
     public function getHighlighted() : string
425 425
     {
426
-        if(!$this->isValid())
426
+        if (!$this->isValid())
427 427
         {
428 428
             return '';
429 429
         }
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
     
435 435
     public function getParamsString() : string
436 436
     {
437
-        if($this->requiresParameters())
437
+        if ($this->requiresParameters())
438 438
         {
439 439
             return $this->paramsString;
440 440
         }
@@ -469,22 +469,22 @@  discard block
 block discarded – undo
469 469
     
470 470
     public final function getCommandType() : string
471 471
     {
472
-        if($this instanceof Mailcode_Commands_Command_Type_Closing)
472
+        if ($this instanceof Mailcode_Commands_Command_Type_Closing)
473 473
         {
474 474
             return 'Closing';
475 475
         }
476 476
         
477
-        if($this instanceof Mailcode_Commands_Command_Type_Opening)
477
+        if ($this instanceof Mailcode_Commands_Command_Type_Opening)
478 478
         {
479 479
             return 'Opening';
480 480
         }
481 481
         
482
-        if($this instanceof Mailcode_Commands_Command_Type_Sibling)
482
+        if ($this instanceof Mailcode_Commands_Command_Type_Sibling)
483 483
         {
484 484
             return 'Sibling';
485 485
         }
486 486
         
487
-        if($this instanceof Mailcode_Commands_Command_Type_Standalone)
487
+        if ($this instanceof Mailcode_Commands_Command_Type_Standalone)
488 488
         {
489 489
             return 'Standalone';
490 490
         }
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
     
535 535
     public function getLogicKeywords() : Mailcode_Commands_LogicKeywords
536 536
     {
537
-        if($this->supportsLogicKeywords() && isset($this->logicKeywords))
537
+        if ($this->supportsLogicKeywords() && isset($this->logicKeywords))
538 538
         {
539 539
             return $this->logicKeywords;
540 540
         }
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
     */
569 569
     public function getTranslationParam(string $name)
570 570
     {
571
-        if(isset($this->translationParams[$name]))
571
+        if (isset($this->translationParams[$name]))
572 572
         {
573 573
             return $this->translationParams[$name];
574 574
         }
Please login to merge, or discard this patch.