Passed
Push — master ( eafb24...c53bf4 )
by Sebastian
04:30
created
src/Mailcode/Parser/Safeguard/Formatter.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
  */
25 25
 abstract class Mailcode_Parser_Safeguard_Formatter
26 26
 {
27
-   /**
28
-    * @var Mailcode_Parser_Safeguard
29
-    */
27
+    /**
28
+     * @var Mailcode_Parser_Safeguard
29
+     */
30 30
     protected $safeguard;
31 31
     
32 32
     public function __construct(Mailcode_Parser_Safeguard $safeguard)
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
     
37 37
     abstract public function format(string $subject) : string;
38 38
     
39
-   /**
40
-    * Resolves a list of positions of needle in the haystack.
41
-    * 
42
-    * @param string $needle
43
-    * @param string $haystack
44
-    * @return int[]
45
-    */
39
+    /**
40
+     * Resolves a list of positions of needle in the haystack.
41
+     * 
42
+     * @param string $needle
43
+     * @param string $haystack
44
+     * @return int[]
45
+     */
46 46
     protected function resolvePositions(string $needle, string $haystack) : array
47 47
     {
48 48
         $lastPos = 0;
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
         return $positions;
58 58
     }
59 59
     
60
-   /**
61
-    * Resolves the newline character used in the string.
62
-    * 
63
-    * @param string $subject
64
-    * @return string
65
-    */
60
+    /**
61
+     * Resolves the newline character used in the string.
62
+     * 
63
+     * @param string $subject
64
+     * @return string
65
+     */
66 66
     protected function resolveNewlineChar(string $subject) : string
67 67
     {
68 68
         $eol = ConvertHelper::detectEOLCharacter($subject);
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
         return PHP_EOL;
76 76
     }
77 77
     
78
-   /**
79
-    * Resolves the list of placeholder strings that need
80
-    * to be formatted. This includes only commands that
81
-    * do not generate content.
82
-    *  
83
-    * @return string[]
84
-    */
78
+    /**
79
+     * Resolves the list of placeholder strings that need
80
+     * to be formatted. This includes only commands that
81
+     * do not generate content.
82
+     *  
83
+     * @return string[]
84
+     */
85 85
     protected function resolvePlaceholderStrings() : array
86 86
     {
87 87
         $placeholders = $this->filterPlaceholders();
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
         return $result;
97 97
     }
98 98
     
99
-   /**
100
-    * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
101
-    */
99
+    /**
100
+     * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
101
+     */
102 102
     protected function filterPlaceholders()
103 103
     {
104 104
         return $this->safeguard->getPlaceholders();
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/SingleLines/Placeholder.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -21,39 +21,39 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class Mailcode_Parser_Safeguard_Formatter_SingleLines_Placeholder
23 23
 {
24
-   /**
25
-    * @var int
26
-    */
24
+    /**
25
+     * @var int
26
+     */
27 27
     protected $eolLength;
28 28
     
29
-   /**
30
-    * @var int
31
-    */
29
+    /**
30
+     * @var int
31
+     */
32 32
     protected $position;
33 33
 
34
-   /**
35
-    * @var string
36
-    */
34
+    /**
35
+     * @var string
36
+     */
37 37
     protected $subject;
38 38
     
39
-   /**
40
-    * @var Mailcode_Parser_Safeguard_Formatter_SingleLines
41
-    */
39
+    /**
40
+     * @var Mailcode_Parser_Safeguard_Formatter_SingleLines
41
+     */
42 42
     protected $formatter;
43 43
     
44
-   /**
45
-    * @var boolean
46
-    */
44
+    /**
45
+     * @var boolean
46
+     */
47 47
     protected $prepend = false;
48 48
 
49
-   /**
50
-    * @var boolean
51
-    */
49
+    /**
50
+     * @var boolean
51
+     */
52 52
     protected $append = false;
53 53
     
54
-   /**
55
-    * @var int
56
-    */
54
+    /**
55
+     * @var int
56
+     */
57 57
     protected $placeholderLength;
58 58
     
59 59
     public function __construct(Mailcode_Parser_Safeguard_Formatter_SingleLines $formatter, string $subject, int $placeholderLength, int $position)
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
         $this->analyzeAppend($subject);
68 68
     }
69 69
     
70
-   /**
71
-    * Whether an EOL character needs to be appended or prepended.
72
-    *  
73
-    * @return bool
74
-    */
70
+    /**
71
+     * Whether an EOL character needs to be appended or prepended.
72
+     *  
73
+     * @return bool
74
+     */
75 75
     public function requiresAdjustment() : bool
76 76
     {
77 77
         return $this->requiresAppend() || $this->requiresPrepend();
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/SingleLines.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class Mailcode_Parser_Safeguard_Formatter_SingleLines extends Mailcode_Parser_Safeguard_Formatter
25 25
 {
26
-   /**
27
-    * @var string
28
-    */
26
+    /**
27
+     * @var string
28
+     */
29 29
     protected $eol;
30 30
     
31
-   /**
32
-    * @var int
33
-    */
31
+    /**
32
+     * @var int
33
+     */
34 34
     protected $eolLength;
35 35
     
36 36
     public function format(string $subject) : string
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
         return $prepend.$placeholder.$append;
120 120
     }
121 121
     
122
-   /**
123
-    * We only use placeholders that contain commands that do
124
-    * not generate contents, since these are the only ones
125
-    * that may need adjusting.
126
-    * 
127
-    * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
128
-    */
122
+    /**
123
+     * We only use placeholders that contain commands that do
124
+     * not generate contents, since these are the only ones
125
+     * that may need adjusting.
126
+     * 
127
+     * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
128
+     */
129 129
     protected function filterPlaceholders()
130 130
     {
131 131
         $placeholders = $this->safeguard->getPlaceholders();
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -61,50 +61,50 @@  discard block
 block discarded – undo
61 61
     
62 62
     const ERROR_NOT_A_SINGLE_LINES_FORMATTER = 47806;
63 63
     
64
-   /**
65
-    * @var Mailcode_Parser
66
-    */
64
+    /**
65
+     * @var Mailcode_Parser
66
+     */
67 67
     protected $parser;
68 68
     
69
-   /**
70
-    * @var Mailcode_Collection
71
-    */
69
+    /**
70
+     * @var Mailcode_Collection
71
+     */
72 72
     protected $commands;
73 73
     
74
-   /**
75
-    * @var string
76
-    */
74
+    /**
75
+     * @var string
76
+     */
77 77
     protected $originalString;
78 78
     
79
-   /**
80
-    * @var Mailcode_Collection
81
-    */
79
+    /**
80
+     * @var Mailcode_Collection
81
+     */
82 82
     protected $collection;
83 83
     
84
-   /**
85
-    * Counter for the placeholders, global for all placeholders.
86
-    * @var integer
87
-    */
84
+    /**
85
+     * Counter for the placeholders, global for all placeholders.
86
+     * @var integer
87
+     */
88 88
     private static $counter = 0;
89 89
     
90
-   /**
91
-    * @var Mailcode_Parser_Safeguard_Placeholder[]
92
-    */
90
+    /**
91
+     * @var Mailcode_Parser_Safeguard_Placeholder[]
92
+     */
93 93
     protected $placeholders;
94 94
     
95
-   /**
96
-    * @var string
97
-    */
95
+    /**
96
+     * @var string
97
+     */
98 98
     protected $delimiter = '__';
99 99
     
100
-   /**
101
-    * @var string[]|NULL
102
-    */
100
+    /**
101
+     * @var string[]|NULL
102
+     */
103 103
     protected $placeholderStrings;
104 104
     
105
-   /**
106
-    * @var Mailcode_Parser_Safeguard_Formatter
107
-    */
105
+    /**
106
+     * @var Mailcode_Parser_Safeguard_Formatter
107
+     */
108 108
     protected $formatter;
109 109
     
110 110
     public function __construct(Mailcode_Parser $parser, string $subject)
@@ -113,25 +113,25 @@  discard block
 block discarded – undo
113 113
         $this->originalString = $subject;
114 114
     }
115 115
     
116
-   /**
117
-    * Retrieves the string the safeguard was created for.
118
-    * 
119
-    * @return string
120
-    */
116
+    /**
117
+     * Retrieves the string the safeguard was created for.
118
+     * 
119
+     * @return string
120
+     */
121 121
     public function getOriginalString() : string
122 122
     {
123 123
         return $this->originalString;
124 124
     }
125 125
     
126
-   /**
127
-    * Sets the delimiter character sequence used to prepend
128
-    * and append to the placeholders.
129
-    * 
130
-    * The delimiter's default is "__" (two underscores).
131
-    * 
132
-    * @param string $delimiter
133
-    * @return Mailcode_Parser_Safeguard
134
-    */
126
+    /**
127
+     * Sets the delimiter character sequence used to prepend
128
+     * and append to the placeholders.
129
+     * 
130
+     * The delimiter's default is "__" (two underscores).
131
+     * 
132
+     * @param string $delimiter
133
+     * @return Mailcode_Parser_Safeguard
134
+     */
135 135
     public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard
136 136
     {
137 137
         if(empty($delimiter))
@@ -153,15 +153,15 @@  discard block
 block discarded – undo
153 153
         return $this->delimiter;
154 154
     }
155 155
     
156
-   /**
157
-    * Retrieves the safe string in which all commands have been replaced
158
-    * by placeholder strings.
159
-    *
160
-    * @return string
161
-    * @throws Mailcode_Exception 
162
-    *
163
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
164
-    */
156
+    /**
157
+     * Retrieves the safe string in which all commands have been replaced
158
+     * by placeholder strings.
159
+     *
160
+     * @return string
161
+     * @throws Mailcode_Exception 
162
+     *
163
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
164
+     */
165 165
     public function makeSafe() : string
166 166
     {
167 167
         $this->requireValidCollection();
@@ -201,10 +201,10 @@  discard block
 block discarded – undo
201 201
         );
202 202
     }
203 203
     
204
-   /**
205
-    * Enables the formatter that ensures that all commands that
206
-    * @return Mailcode_Parser_Safeguard_Formatter_SingleLines
207
-    */
204
+    /**
205
+     * Enables the formatter that ensures that all commands that
206
+     * @return Mailcode_Parser_Safeguard_Formatter_SingleLines
207
+     */
208 208
     public function selectSingleLinesFormatter() : Mailcode_Parser_Safeguard_Formatter_SingleLines
209 209
     {
210 210
         $formatter = $this->selectFormatter('SingleLines');
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
         );
225 225
     }
226 226
     
227
-   /**
228
-    * Retrieves an associative array with pairs of
229
-    * [placeholder string => replacement text]. 
230
-    * 
231
-    * @param bool $highlighted
232
-    * @return string[]string
233
-    */
227
+    /**
228
+     * Retrieves an associative array with pairs of
229
+     * [placeholder string => replacement text]. 
230
+     * 
231
+     * @param bool $highlighted
232
+     * @return string[]string
233
+     */
234 234
     protected function getReplaces(bool $highlighted=false) : array
235 235
     {
236 236
         $placeholders = $this->getPlaceholders();
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
     }
258 258
     
259 259
     
260
-   /**
261
-    * Retrieves all placeholders that have to be added to
262
-    * the subject text.
263
-    * 
264
-    * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
265
-    */
260
+    /**
261
+     * Retrieves all placeholders that have to be added to
262
+     * the subject text.
263
+     * 
264
+     * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[]
265
+     */
266 266
     public function getPlaceholders()
267 267
     {
268 268
         if(isset($this->placeholders))
@@ -314,46 +314,46 @@  discard block
 block discarded – undo
314 314
         return str_replace($placeholderStrings, array_values($replaces), $string);
315 315
     }
316 316
     
317
-   /**
318
-    * Makes the string whole again after transforming or filtering it,
319
-    * by replacing the command placeholders with the original commands.
320
-    *
321
-    * @param string $string
322
-    * @return string
323
-    * @throws Mailcode_Exception
324
-    *
325
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
326
-    * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING
327
-    */
317
+    /**
318
+     * Makes the string whole again after transforming or filtering it,
319
+     * by replacing the command placeholders with the original commands.
320
+     *
321
+     * @param string $string
322
+     * @return string
323
+     * @throws Mailcode_Exception
324
+     *
325
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
326
+     * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING
327
+     */
328 328
     public function makeWhole(string $string) : string
329 329
     {
330 330
         return $this->restore($string, false);
331 331
     }
332 332
 
333
-   /**
334
-    * Like makeWhole(), but replaces the commands with a syntax
335
-    * highlighted version, meant for human readable texts only.
336
-    * 
337
-    * Note: the commands lose their functionality (They cannot be 
338
-    * parsed from that string again).
339
-    *
340
-    * @param string $string
341
-    * @return string
342
-    * @throws Mailcode_Exception
343
-    *
344
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
345
-    * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING
346
-    */
333
+    /**
334
+     * Like makeWhole(), but replaces the commands with a syntax
335
+     * highlighted version, meant for human readable texts only.
336
+     * 
337
+     * Note: the commands lose their functionality (They cannot be 
338
+     * parsed from that string again).
339
+     *
340
+     * @param string $string
341
+     * @return string
342
+     * @throws Mailcode_Exception
343
+     *
344
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
345
+     * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING
346
+     */
347 347
     public function makeHighlighted(string $string) : string
348 348
     {
349 349
         return $this->restore($string, true);
350 350
     }
351 351
     
352
-   /**
353
-    * Retrieves the commands collection contained in the string.
354
-    * 
355
-    * @return Mailcode_Collection
356
-    */
352
+    /**
353
+     * Retrieves the commands collection contained in the string.
354
+     * 
355
+     * @return Mailcode_Collection
356
+     */
357 357
     public function getCollection() : Mailcode_Collection
358 358
     {
359 359
         if(isset($this->collection))
@@ -371,11 +371,11 @@  discard block
 block discarded – undo
371 371
         return $this->getCollection()->isValid();
372 372
     }
373 373
     
374
-   /**
375
-    * @throws Mailcode_Exception
376
-    * 
377
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
378
-    */
374
+    /**
375
+     * @throws Mailcode_Exception
376
+     * 
377
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
378
+     */
379 379
     protected function requireValidCollection() : void
380 380
     {
381 381
         if($this->getCollection()->isValid())
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
         );
395 395
     }
396 396
     
397
-   /**
398
-    * Retrieves a list of all placeholder IDs used in the text.
399
-    * 
400
-    * @return string[]
401
-    */
397
+    /**
398
+     * Retrieves a list of all placeholder IDs used in the text.
399
+     * 
400
+     * @return string[]
401
+     */
402 402
     public function getPlaceholderStrings() : array
403 403
     {
404 404
         if(isset($this->placeholderStrings))
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
         return in_array($subject, $ids);
426 426
     }
427 427
     
428
-   /**
429
-    * Retrieves a placeholder instance by its ID.
430
-    * 
431
-    * @param int $id
432
-    * @throws Mailcode_Exception If the placeholder was not found.
433
-    * @return Mailcode_Parser_Safeguard_Placeholder
434
-    */
428
+    /**
429
+     * Retrieves a placeholder instance by its ID.
430
+     * 
431
+     * @param int $id
432
+     * @throws Mailcode_Exception If the placeholder was not found.
433
+     * @return Mailcode_Parser_Safeguard_Placeholder
434
+     */
435 435
     public function getPlaceholderByID(int $id) : Mailcode_Parser_Safeguard_Placeholder
436 436
     {
437 437
         $placeholders = $this->getPlaceholders();
@@ -454,13 +454,13 @@  discard block
 block discarded – undo
454 454
         );
455 455
     }
456 456
     
457
-   /**
458
-    * Retrieves a placeholder instance by its replacement text.
459
-    * 
460
-    * @param string $string
461
-    * @throws Mailcode_Exception
462
-    * @return Mailcode_Parser_Safeguard_Placeholder
463
-    */
457
+    /**
458
+     * Retrieves a placeholder instance by its replacement text.
459
+     * 
460
+     * @param string $string
461
+     * @throws Mailcode_Exception
462
+     * @return Mailcode_Parser_Safeguard_Placeholder
463
+     */
464 464
     public function getPlaceholderByString(string $string) : Mailcode_Parser_Safeguard_Placeholder
465 465
     {
466 466
         $placeholders = $this->getPlaceholders();
Please login to merge, or discard this patch.