Passed
Push — master ( 75ee28...758f58 )
by Sebastian
04:00
created
src/Mailcode/Factory.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
     const ERROR_INVALID_COMMAND_CREATED = 50001;
24 24
     const ERROR_UNEXPECTED_COMMAND_TYPE = 50002;
25 25
 
26
-   /**
27
-    * @var Mailcode_Factory_CommandSets
28
-    */
26
+    /**
27
+     * @var Mailcode_Factory_CommandSets
28
+     */
29 29
     private static $commandSets;
30 30
     
31
-   /**
32
-    * Creates a ShowVariable command.
33
-    * 
34
-    * @param string $variableName A variable name, with or without the $ sign prepended.
35
-    * @return Mailcode_Commands_Command_ShowVariable
36
-    */
31
+    /**
32
+     * Creates a ShowVariable command.
33
+     * 
34
+     * @param string $variableName A variable name, with or without the $ sign prepended.
35
+     * @return Mailcode_Commands_Command_ShowVariable
36
+     */
37 37
     public static function showVar(string $variableName) : Mailcode_Commands_Command_ShowVariable
38 38
     {
39 39
         return self::$commandSets->show()->showVar($variableName);
@@ -65,41 +65,41 @@  discard block
 block discarded – undo
65 65
         return self::$commandSets->show()->showNumber($variableName, $formatString);
66 66
     }
67 67
 
68
-   /**
69
-    * Creates a ShowSnippet command.
70
-    *
71
-    * @param string $snippetName A snippet name, with or without the $ sign prepended.
72
-    * @return Mailcode_Commands_Command_ShowSnippet
73
-    */
68
+    /**
69
+     * Creates a ShowSnippet command.
70
+     *
71
+     * @param string $snippetName A snippet name, with or without the $ sign prepended.
72
+     * @return Mailcode_Commands_Command_ShowSnippet
73
+     */
74 74
     public static function showSnippet(string $snippetName) : Mailcode_Commands_Command_ShowSnippet
75 75
     {
76 76
         return self::$commandSets->show()->showSnippet($snippetName);
77 77
     }
78 78
     
79
-   /**
80
-    * Creates a SetVariable command.
81
-    * 
82
-    * @param string $variableName A variable name, with or without the $ sign prepended.
83
-    * @param string $value
84
-    * @param bool $quoteValue Whether to treat the value as a string literal, and add quotes to it.
85
-    * @return Mailcode_Commands_Command_SetVariable
86
-    * @throws Mailcode_Factory_Exception
87
-    * 
88
-    * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED
89
-    */
79
+    /**
80
+     * Creates a SetVariable command.
81
+     * 
82
+     * @param string $variableName A variable name, with or without the $ sign prepended.
83
+     * @param string $value
84
+     * @param bool $quoteValue Whether to treat the value as a string literal, and add quotes to it.
85
+     * @return Mailcode_Commands_Command_SetVariable
86
+     * @throws Mailcode_Factory_Exception
87
+     * 
88
+     * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED
89
+     */
90 90
     public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable
91 91
     {
92 92
         return self::$commandSets->set()->setVar($variableName, $value, $quoteValue);
93 93
     }
94 94
     
95
-   /**
96
-    * Like setVar(), but treats the value as a string literal
97
-    * and automatically adds quotes to it.
98
-    * 
99
-    * @param string $variableName
100
-    * @param string $value
101
-    * @return Mailcode_Commands_Command_SetVariable
102
-    */
95
+    /**
96
+     * Like setVar(), but treats the value as a string literal
97
+     * and automatically adds quotes to it.
98
+     * 
99
+     * @param string $variableName
100
+     * @param string $value
101
+     * @return Mailcode_Commands_Command_SetVariable
102
+     */
103 103
     public static function setVarString(string $variableName, string $value) : Mailcode_Commands_Command_SetVariable
104 104
     {
105 105
         return self::$commandSets->set()->setVar($variableName, $value, true);
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
     }
257 257
 
258 258
     /**
259
-    * Creates if contains command, with several search terms.
260
-    * 
261
-    * @param string $variable
262
-    * @param string[] $searchTerms List of search terms. Do not add surrounding quotes.
263
-    * @param bool $caseInsensitive
264
-    * @return Mailcode_Commands_Command_If_Contains
265
-    */
259
+     * Creates if contains command, with several search terms.
260
+     * 
261
+     * @param string $variable
262
+     * @param string[] $searchTerms List of search terms. Do not add surrounding quotes.
263
+     * @param bool $caseInsensitive
264
+     * @return Mailcode_Commands_Command_If_Contains
265
+     */
266 266
     public static function ifContainsAny(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains
267 267
     {
268 268
         return self::$commandSets->if()->ifContains($variable, $searchTerms, $caseInsensitive);
@@ -273,14 +273,14 @@  discard block
 block discarded – undo
273 273
         return self::$commandSets->elseIf()->elseIfContains($variable, array($search), $caseInsensitive);
274 274
     }
275 275
     
276
-   /**
277
-    * Creates else if contains command, with several search terms.
278
-    * 
279
-    * @param string $variable
280
-    * @param string[] $searchTerms List of search terms. Do not add surrounding quotes.
281
-    * @param bool $caseInsensitive
282
-    * @return Mailcode_Commands_Command_ElseIf_Contains
283
-    */
276
+    /**
277
+     * Creates else if contains command, with several search terms.
278
+     * 
279
+     * @param string $variable
280
+     * @param string[] $searchTerms List of search terms. Do not add surrounding quotes.
281
+     * @param bool $caseInsensitive
282
+     * @return Mailcode_Commands_Command_ElseIf_Contains
283
+     */
284 284
     public static function elseIfContainsAny(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains
285 285
     {
286 286
         return self::$commandSets->elseIf()->elseIfContains($variable, $searchTerms, $caseInsensitive);
@@ -301,34 +301,34 @@  discard block
 block discarded – undo
301 301
         return self::$commandSets->misc()->for($sourceVariable, $loopVariable);
302 302
     }
303 303
     
304
-   /**
305
-    * Creates a renderer instance, which can be used to easily
306
-    * create and convert commands to strings.
307
-    * 
308
-    * @return Mailcode_Renderer
309
-    */
304
+    /**
305
+     * Creates a renderer instance, which can be used to easily
306
+     * create and convert commands to strings.
307
+     * 
308
+     * @return Mailcode_Renderer
309
+     */
310 310
     public static function createRenderer() : Mailcode_Renderer
311 311
     {
312 312
         return new Mailcode_Renderer();
313 313
     }
314 314
     
315
-   /**
316
-    * Creates a printer instance, which works like the renderer,
317
-    * but outputs the generated strings to standard output.
318
-    * 
319
-    * @return Mailcode_Printer
320
-    */
315
+    /**
316
+     * Creates a printer instance, which works like the renderer,
317
+     * but outputs the generated strings to standard output.
318
+     * 
319
+     * @return Mailcode_Printer
320
+     */
321 321
     public static function createPrinter() : Mailcode_Printer
322 322
     {
323 323
         return new Mailcode_Printer();
324 324
     }
325 325
     
326
-   /**
327
-    * Gets/creates the global instance of the date format info
328
-    * class, used to handle date formatting aspects.
329
-    * 
330
-    * @return Mailcode_Date_FormatInfo
331
-    */
326
+    /**
327
+     * Gets/creates the global instance of the date format info
328
+     * class, used to handle date formatting aspects.
329
+     * 
330
+     * @return Mailcode_Date_FormatInfo
331
+     */
332 332
     public static function createDateInfo() : Mailcode_Date_FormatInfo
333 333
     {
334 334
         return Mailcode_Date_FormatInfo::getInstance();
Please login to merge, or discard this patch.
src/Mailcode/Collection.php 1 patch
Indentation   +55 added lines, -55 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)
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
     }
247 247
 
248 248
     /**
249
-    * Retrieves only show variable commands in the collection, if any.
250
-    * 
251
-    * @return Mailcode_Commands_Command_ShowVariable[]
252
-    */
249
+     * Retrieves only show variable commands in the collection, if any.
250
+     * 
251
+     * @return Mailcode_Commands_Command_ShowVariable[]
252
+     */
253 253
     public function getShowVariableCommands()
254 254
     {
255 255
         return $this->getCommandsByClass(Mailcode_Commands_Command_ShowVariable::class);
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
         return $this->getCommandsByClass(Mailcode_Commands_Command_For::class);
264 264
     }
265 265
 
266
-   /**
267
-    * Retrieves only show date commands in the collection, if any.
268
-    *
269
-    * @return Mailcode_Commands_Command_ShowDate[]
270
-    */
266
+    /**
267
+     * Retrieves only show date commands in the collection, if any.
268
+     *
269
+     * @return Mailcode_Commands_Command_ShowDate[]
270
+     */
271 271
     public function getShowDateCommands() : array
272 272
     {
273 273
         return $this->getCommandsByClass(Mailcode_Commands_Command_ShowDate::class);
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement/Tokenizer.php 1 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
     const ERROR_TOKENIZE_METHOD_MISSING = 49801;
25 25
     const ERROR_INVALID_TOKEN_CREATED = 49802;
26 26
     
27
-   /**
28
-    * @var string[]
29
-    */
27
+    /**
28
+     * @var string[]
29
+     */
30 30
     protected $operands = array(
31 31
         '==',
32 32
         '<=',
@@ -41,18 +41,18 @@  discard block
 block discarded – undo
41 41
         '<'
42 42
     );
43 43
     
44
-   /**
45
-    * @var string[]
46
-    */
44
+    /**
45
+     * @var string[]
46
+     */
47 47
     protected $keywords = array(
48 48
         'in:',
49 49
         'insensitive:',
50 50
         'urlencode:'
51 51
     );
52 52
     
53
-   /**
54
-    * @var string
55
-    */
53
+    /**
54
+     * @var string
55
+     */
56 56
     protected $delimiter = '§§';
57 57
     
58 58
     /**
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
         'extract_tokens'
70 70
     );
71 71
     
72
-   /**
73
-    * @var Mailcode_Parser_Statement
74
-    */
72
+    /**
73
+     * @var Mailcode_Parser_Statement
74
+     */
75 75
     protected $statement;
76 76
     
77
-   /**
78
-    * @var string
79
-    */
77
+    /**
78
+     * @var string
79
+     */
80 80
     protected $tokenized;
81 81
     
82
-   /**
83
-    * @var Mailcode_Parser_Statement_Tokenizer_Token[]
84
-    */
82
+    /**
83
+     * @var Mailcode_Parser_Statement_Tokenizer_Token[]
84
+     */
85 85
     protected $tokensTemporary = array();
86 86
     
87 87
     /**
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
      */
90 90
     protected $tokensOrdered = array();
91 91
     
92
-   /**
93
-    * @var string[]
94
-    */
92
+    /**
93
+     * @var string[]
94
+     */
95 95
     protected static $ids = array();
96 96
     
97 97
     public function __construct(Mailcode_Parser_Statement $statement)
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
         $this->tokenize($statement->getStatementString());
102 102
     }
103 103
 
104
-   /**
105
-    * Retrieves all tokens detected in the statement string, in 
106
-    * the order they were found.
107
-    * 
108
-    * @return Mailcode_Parser_Statement_Tokenizer_Token[]
109
-    */
104
+    /**
105
+     * Retrieves all tokens detected in the statement string, in 
106
+     * the order they were found.
107
+     * 
108
+     * @return Mailcode_Parser_Statement_Tokenizer_Token[]
109
+     */
110 110
     public function getTokens()
111 111
     {
112 112
         return $this->tokensOrdered;
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
         return !empty($this->tokensOrdered);
118 118
     }
119 119
     
120
-   /**
121
-    * Whether there were any unknown tokens in the statement.
122
-    * 
123
-    * @return bool
124
-    */
120
+    /**
121
+     * Whether there were any unknown tokens in the statement.
122
+     * 
123
+     * @return bool
124
+     */
125 125
     public function hasUnknown() : bool
126 126
     {
127 127
         $unknown = $this->getUnknown();
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
         return !empty($unknown);
130 130
     }
131 131
     
132
-   /**
133
-    * Retrieves all unknown content tokens, if any.
134
-    * 
135
-    * @return \Mailcode\Mailcode_Parser_Statement_Tokenizer_Token_Unknown[]
136
-    */
132
+    /**
133
+     * Retrieves all unknown content tokens, if any.
134
+     * 
135
+     * @return \Mailcode\Mailcode_Parser_Statement_Tokenizer_Token_Unknown[]
136
+     */
137 137
     public function getUnknown()
138 138
     {
139 139
         $result = array();
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
         }
204 204
     }
205 205
 
206
-   /**
207
-    * Registers a token to add in the statement string.
208
-    * 
209
-    * @param string $type
210
-    * @param string $matchedText
211
-    * @param mixed $subject
212
-    */
206
+    /**
207
+     * Registers a token to add in the statement string.
208
+     * 
209
+     * @param string $type
210
+     * @param string $matchedText
211
+     * @param mixed $subject
212
+     */
213 213
     protected function registerToken(string $type, string $matchedText, $subject=null) : void
214 214
     {
215 215
         $this->tokensTemporary[] = $this->createToken($type, $matchedText, $subject);
@@ -288,11 +288,11 @@  discard block
 block discarded – undo
288 288
         return null;
289 289
     }
290 290
     
291
-   /**
292
-    * Some WYSIWYG editors like using pretty quotes instead
293
-    * of the usual double quotes. This simply replaces all
294
-    * occurrences with the regular variant.
295
-    */
291
+    /**
292
+     * Some WYSIWYG editors like using pretty quotes instead
293
+     * of the usual double quotes. This simply replaces all
294
+     * occurrences with the regular variant.
295
+     */
296 296
     protected function tokenize_normalize_quotes() : void
297 297
     {
298 298
         $this->tokenized = str_replace(array('“', '”'), '"', $this->tokenized);
@@ -381,13 +381,13 @@  discard block
 block discarded – undo
381 381
         }
382 382
     }
383 383
     
384
-   /**
385
-    * Generates a unique alphabet-based ID without numbers
386
-    * to use as token name, to avoid conflicts with the
387
-    * numbers detection.
388
-    * 
389
-    * @return string
390
-    */
384
+    /**
385
+     * Generates a unique alphabet-based ID without numbers
386
+     * to use as token name, to avoid conflicts with the
387
+     * numbers detection.
388
+     * 
389
+     * @return string
390
+     */
391 391
     protected function generateID() : string
392 392
     {
393 393
         static $alphas;
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard.php 1 patch
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -55,50 +55,50 @@  discard block
 block discarded – undo
55 55
     const ERROR_EMPTY_DELIMITER = 47803;
56 56
     const ERROR_PLACEHOLDER_NOT_FOUND = 47804;
57 57
     
58
-   /**
59
-    * @var Mailcode_Parser
60
-    */
58
+    /**
59
+     * @var Mailcode_Parser
60
+     */
61 61
     protected $parser;
62 62
     
63
-   /**
64
-    * @var Mailcode_Collection
65
-    */
63
+    /**
64
+     * @var Mailcode_Collection
65
+     */
66 66
     protected $commands;
67 67
     
68
-   /**
69
-    * @var string
70
-    */
68
+    /**
69
+     * @var string
70
+     */
71 71
     protected $originalString;
72 72
     
73
-   /**
74
-    * @var Mailcode_Collection
75
-    */
73
+    /**
74
+     * @var Mailcode_Collection
75
+     */
76 76
     protected $collection;
77 77
     
78
-   /**
79
-    * Counter for the placeholders, global for all placeholders.
80
-    * @var integer
81
-    */
78
+    /**
79
+     * Counter for the placeholders, global for all placeholders.
80
+     * @var integer
81
+     */
82 82
     private static $counter = 0;
83 83
     
84
-   /**
85
-    * @var Mailcode_Parser_Safeguard_Placeholder[]
86
-    */
84
+    /**
85
+     * @var Mailcode_Parser_Safeguard_Placeholder[]
86
+     */
87 87
     protected $placeholders;
88 88
     
89
-   /**
90
-    * @var string
91
-    */
89
+    /**
90
+     * @var string
91
+     */
92 92
     protected $delimiter = '__';
93 93
     
94
-   /**
95
-    * @var string[]|NULL
96
-    */
94
+    /**
95
+     * @var string[]|NULL
96
+     */
97 97
     protected $placeholderStrings;
98 98
     
99
-   /**
100
-    * @var Mailcode_Parser_Safeguard_Formatting|NULL
101
-    */
99
+    /**
100
+     * @var Mailcode_Parser_Safeguard_Formatting|NULL
101
+     */
102 102
     private $formatting = null;
103 103
     
104 104
     public function __construct(Mailcode_Parser $parser, string $subject)
@@ -107,25 +107,25 @@  discard block
 block discarded – undo
107 107
         $this->originalString = $subject;
108 108
     }
109 109
     
110
-   /**
111
-    * Retrieves the string the safeguard was created for.
112
-    * 
113
-    * @return string
114
-    */
110
+    /**
111
+     * Retrieves the string the safeguard was created for.
112
+     * 
113
+     * @return string
114
+     */
115 115
     public function getOriginalString() : string
116 116
     {
117 117
         return $this->originalString;
118 118
     }
119 119
     
120
-   /**
121
-    * Sets the delimiter character sequence used to prepend
122
-    * and append to the placeholders.
123
-    * 
124
-    * The delimiter's default is "__" (two underscores).
125
-    * 
126
-    * @param string $delimiter
127
-    * @return Mailcode_Parser_Safeguard
128
-    */
120
+    /**
121
+     * Sets the delimiter character sequence used to prepend
122
+     * and append to the placeholders.
123
+     * 
124
+     * The delimiter's default is "__" (two underscores).
125
+     * 
126
+     * @param string $delimiter
127
+     * @return Mailcode_Parser_Safeguard
128
+     */
129 129
     public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard
130 130
     {
131 131
         if(empty($delimiter))
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
         return $this->delimiter;
148 148
     }
149 149
     
150
-   /**
151
-    * Retrieves the safe string in which all commands have been replaced
152
-    * by placeholder strings.
153
-    *
154
-    * @return string
155
-    * @throws Mailcode_Exception 
156
-    *
157
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
158
-    */
150
+    /**
151
+     * Retrieves the safe string in which all commands have been replaced
152
+     * by placeholder strings.
153
+     *
154
+     * @return string
155
+     * @throws Mailcode_Exception 
156
+     *
157
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
158
+     */
159 159
     public function makeSafe() : string
160 160
     {
161 161
         $this->requireValidCollection();
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
         return $this->makeSafePartial();
164 164
     }
165 165
     
166
-   /**
167
-    * Like makeSafe(), but allows partial (invalid) commands: use this
168
-    * if the subject string may contain only part of the whole set of
169
-    * commands. 
170
-    * 
171
-    * Example: parsing a text with an opening if statement, without the 
172
-    * matching end statement.
173
-    * 
174
-    * @return string
175
-    */
166
+    /**
167
+     * Like makeSafe(), but allows partial (invalid) commands: use this
168
+     * if the subject string may contain only part of the whole set of
169
+     * commands. 
170
+     * 
171
+     * Example: parsing a text with an opening if statement, without the 
172
+     * matching end statement.
173
+     * 
174
+     * @return string
175
+     */
176 176
     public function makeSafePartial() : string
177 177
     {
178 178
         $placeholders = $this->getPlaceholders();
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
         }
241 241
     }
242 242
     
243
-   /**
244
-    * Creates a formatting handler, which can be used to specify
245
-    * which formattings to use for the commands in the subject string.
246
-    * 
247
-    * @param Mailcode_StringContainer|string $subject
248
-    * @return Mailcode_Parser_Safeguard_Formatting
249
-    */
243
+    /**
244
+     * Creates a formatting handler, which can be used to specify
245
+     * which formattings to use for the commands in the subject string.
246
+     * 
247
+     * @param Mailcode_StringContainer|string $subject
248
+     * @return Mailcode_Parser_Safeguard_Formatting
249
+     */
250 250
     public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting
251 251
     {
252 252
         if(is_string($subject))
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
         return new Mailcode_Parser_Safeguard_Formatting($this, $subject);
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,16 +314,16 @@  discard block
 block discarded – undo
314 314
         return $formatting->toString();
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
-    */
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
+     */
327 327
     public function makeWhole(string $string) : string
328 328
     {
329 329
         return $this->restore(
@@ -333,15 +333,15 @@  discard block
 block discarded – undo
333 333
         );
334 334
     }
335 335
     
336
-   /**
337
-    * Like `makeWhole()`, but ignores missing command placeholders.
338
-    *
339
-    * @param string $string
340
-    * @return string
341
-    * @throws Mailcode_Exception
342
-    *
343
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
344
-    */
336
+    /**
337
+     * Like `makeWhole()`, but ignores missing command placeholders.
338
+     *
339
+     * @param string $string
340
+     * @return string
341
+     * @throws Mailcode_Exception
342
+     *
343
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
344
+     */
345 345
     public function makeWholePartial(string $string) : string
346 346
     {
347 347
         return $this->restore(
@@ -351,19 +351,19 @@  discard block
 block discarded – undo
351 351
         );
352 352
     }
353 353
 
354
-   /**
355
-    * Like `makeWhole()`, but replaces the commands with a syntax
356
-    * highlighted version, meant for human readable texts only.
357
-    * 
358
-    * Note: the commands lose their functionality (They cannot be 
359
-    * parsed from that string again).
360
-    *
361
-    * @param string $string
362
-    * @return string
363
-    * @throws Mailcode_Exception
364
-    *
365
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
366
-    */
354
+    /**
355
+     * Like `makeWhole()`, but replaces the commands with a syntax
356
+     * highlighted version, meant for human readable texts only.
357
+     * 
358
+     * Note: the commands lose their functionality (They cannot be 
359
+     * parsed from that string again).
360
+     *
361
+     * @param string $string
362
+     * @return string
363
+     * @throws Mailcode_Exception
364
+     *
365
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
366
+     */
367 367
     public function makeHighlighted(string $string) : string
368 368
     {
369 369
         return $this->restore(
@@ -373,15 +373,15 @@  discard block
 block discarded – undo
373 373
         );
374 374
     }
375 375
     
376
-   /**
377
-    * Like `makeHighlighted()`, but ignores missing command placeholders.
378
-    * 
379
-    * @param string $string
380
-    * @return string
381
-    * @throws Mailcode_Exception
382
-    *
383
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
384
-    */
376
+    /**
377
+     * Like `makeHighlighted()`, but ignores missing command placeholders.
378
+     * 
379
+     * @param string $string
380
+     * @return string
381
+     * @throws Mailcode_Exception
382
+     *
383
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
384
+     */
385 385
     public function makeHighlightedPartial(string $string) : string
386 386
     {
387 387
         return $this->restore(
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
         );
392 392
     }
393 393
     
394
-   /**
395
-    * Retrieves the commands collection contained in the string.
396
-    * 
397
-    * @return Mailcode_Collection
398
-    */
394
+    /**
395
+     * Retrieves the commands collection contained in the string.
396
+     * 
397
+     * @return Mailcode_Collection
398
+     */
399 399
     public function getCollection() : Mailcode_Collection
400 400
     {
401 401
         if(isset($this->collection))
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
         return $this->getCollection()->isValid();
414 414
     }
415 415
     
416
-   /**
417
-    * @throws Mailcode_Exception
418
-    * 
419
-    * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
420
-    */
416
+    /**
417
+     * @throws Mailcode_Exception
418
+     * 
419
+     * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS
420
+     */
421 421
     protected function requireValidCollection() : void
422 422
     {
423 423
         if($this->getCollection()->isValid())
@@ -436,11 +436,11 @@  discard block
 block discarded – undo
436 436
         );
437 437
     }
438 438
     
439
-   /**
440
-    * Retrieves a list of all placeholder IDs used in the text.
441
-    * 
442
-    * @return string[]
443
-    */
439
+    /**
440
+     * Retrieves a list of all placeholder IDs used in the text.
441
+     * 
442
+     * @return string[]
443
+     */
444 444
     public function getPlaceholderStrings() : array
445 445
     {
446 446
         if(is_array($this->placeholderStrings))
@@ -467,13 +467,13 @@  discard block
 block discarded – undo
467 467
         return in_array($subject, $ids);
468 468
     }
469 469
     
470
-   /**
471
-    * Retrieves a placeholder instance by its ID.
472
-    * 
473
-    * @param int $id
474
-    * @throws Mailcode_Exception If the placeholder was not found.
475
-    * @return Mailcode_Parser_Safeguard_Placeholder
476
-    */
470
+    /**
471
+     * Retrieves a placeholder instance by its ID.
472
+     * 
473
+     * @param int $id
474
+     * @throws Mailcode_Exception If the placeholder was not found.
475
+     * @return Mailcode_Parser_Safeguard_Placeholder
476
+     */
477 477
     public function getPlaceholderByID(int $id) : Mailcode_Parser_Safeguard_Placeholder
478 478
     {
479 479
         $placeholders = $this->getPlaceholders();
@@ -496,13 +496,13 @@  discard block
 block discarded – undo
496 496
         );
497 497
     }
498 498
     
499
-   /**
500
-    * Retrieves a placeholder instance by its replacement text.
501
-    * 
502
-    * @param string $string
503
-    * @throws Mailcode_Exception
504
-    * @return Mailcode_Parser_Safeguard_Placeholder
505
-    */
499
+    /**
500
+     * Retrieves a placeholder instance by its replacement text.
501
+     * 
502
+     * @param string $string
503
+     * @throws Mailcode_Exception
504
+     * @return Mailcode_Parser_Safeguard_Placeholder
505
+     */
506 506
     public function getPlaceholderByString(string $string) : Mailcode_Parser_Safeguard_Placeholder
507 507
     {
508 508
         $placeholders = $this->getPlaceholders();
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command.php 1 patch
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -35,44 +35,44 @@  discard block
 block discarded – undo
35 35
 
36 36
     const META_URL_ENCODING = 'url_encoding';
37 37
 
38
-   /**
39
-    * @var string
40
-    */
38
+    /**
39
+     * @var string
40
+     */
41 41
     protected $type = '';
42 42
 
43
-   /**
44
-    * @var string
45
-    */
43
+    /**
44
+     * @var string
45
+     */
46 46
     protected $paramsString = '';
47 47
     
48
-   /**
49
-    * @var string
50
-    */
48
+    /**
49
+     * @var string
50
+     */
51 51
     protected $matchedText = '';
52 52
 
53
-   /**
54
-    * @var string
55
-    */
53
+    /**
54
+     * @var string
55
+     */
56 56
     protected $hash = '';
57 57
     
58
-   /**
59
-    * @var \AppUtils\OperationResult
60
-    */
58
+    /**
59
+     * @var \AppUtils\OperationResult
60
+     */
61 61
     protected $validationResult = null;
62 62
     
63
-   /**
64
-    * @var \Mailcode\Mailcode
65
-    */
63
+    /**
64
+     * @var \Mailcode\Mailcode
65
+     */
66 66
     protected $mailcode;
67 67
     
68
-   /**
69
-    * @var \Mailcode\Mailcode_Parser_Statement
70
-    */
68
+    /**
69
+     * @var \Mailcode\Mailcode_Parser_Statement
70
+     */
71 71
     protected $params;
72 72
 
73
-   /**
74
-    * @var string[] 
75
-    */
73
+    /**
74
+     * @var string[] 
75
+     */
76 76
     protected $validations = array(
77 77
         'params_empty',
78 78
         'params_keywords',
@@ -81,24 +81,24 @@  discard block
 block discarded – undo
81 81
         'type_unsupported'
82 82
     );
83 83
     
84
-   /**
85
-    * @var string
86
-    */
84
+    /**
85
+     * @var string
86
+     */
87 87
     protected $comment = '';
88 88
     
89
-   /**
90
-    * @var Mailcode_Commands_LogicKeywords|NULL
91
-    */
89
+    /**
90
+     * @var Mailcode_Commands_LogicKeywords|NULL
91
+     */
92 92
     protected $logicKeywords;
93 93
     
94
-   /**
95
-    * @var Mailcode_Parser_Statement_Validator
96
-    */
94
+    /**
95
+     * @var Mailcode_Parser_Statement_Validator
96
+     */
97 97
     protected $validator;
98 98
     
99
-   /**
100
-    * @var boolean
101
-    */
99
+    /**
100
+     * @var boolean
101
+     */
102 102
     private $validated = false;
103 103
 
104 104
     /**
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
         
134 134
     }
135 135
 
136
-   /**
137
-    * Sets the command's parent opening command, if any.
138
-    * NOTE: This is set automatically by the parser, and
139
-    * should not be called manually.
140
-    *
141
-    * @param Mailcode_Commands_Command $command
142
-    */
136
+    /**
137
+     * Sets the command's parent opening command, if any.
138
+     * NOTE: This is set automatically by the parser, and
139
+     * should not be called manually.
140
+     *
141
+     * @param Mailcode_Commands_Command $command
142
+     */
143 143
     public function setParent(Mailcode_Commands_Command $command) : void
144 144
     {
145 145
         $this->parent = $command;
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
         return $this->parent;
156 156
     }
157 157
     
158
-   /**
159
-    * @return string The ID of the command = the name of the command class file.
160
-    */
158
+    /**
159
+     * @return string The ID of the command = the name of the command class file.
160
+     */
161 161
     public function getID() : string
162 162
     {
163 163
         // account for commands with types: If_Variable should still return If.
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
         return array_shift($tokens);
167 167
     }
168 168
     
169
-   /**
170
-    * Sets an optional comment that is not used anywhere, but
171
-    * can be used by the application to track why a command is
172
-    * used somewhere. 
173
-    * 
174
-    * @param string $comment
175
-    * @return Mailcode_Commands_Command
176
-    */
169
+    /**
170
+     * Sets an optional comment that is not used anywhere, but
171
+     * can be used by the application to track why a command is
172
+     * used somewhere. 
173
+     * 
174
+     * @param string $comment
175
+     * @return Mailcode_Commands_Command
176
+     */
177 177
     public function setComment(string $comment) : Mailcode_Commands_Command
178 178
     {
179 179
         $this->comment = $comment;
@@ -181,34 +181,34 @@  discard block
 block discarded – undo
181 181
         return $this;
182 182
     }
183 183
     
184
-   /**
185
-    * Retrieves the previously set comment, if any.
186
-    * 
187
-    * @return string
188
-    */
184
+    /**
185
+     * Retrieves the previously set comment, if any.
186
+     * 
187
+     * @return string
188
+     */
189 189
     public function getComment() : string
190 190
     {
191 191
         return $this->comment;
192 192
     }
193 193
     
194
-   /**
195
-    * Checks whether this is a dummy command, which is only
196
-    * used to access information on the command type. It cannot
197
-    * be used as an actual live command.
198
-    * 
199
-    * @return bool
200
-    */
194
+    /**
195
+     * Checks whether this is a dummy command, which is only
196
+     * used to access information on the command type. It cannot
197
+     * be used as an actual live command.
198
+     * 
199
+     * @return bool
200
+     */
201 201
     public function isDummy() : bool
202 202
     {
203 203
         return $this->type === '__dummy';
204 204
     }
205 205
     
206
-   /**
207
-    * Retrieves a hash of the actual matched command string,
208
-    * which is used in collections to detect duplicate commands.
209
-    * 
210
-    * @return string
211
-    */
206
+    /**
207
+     * Retrieves a hash of the actual matched command string,
208
+     * which is used in collections to detect duplicate commands.
209
+     * 
210
+     * @return string
211
+     */
212 212
     public function getHash() : string
213 213
     {
214 214
         $this->requireNonDummy();
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
         return $this->validationResult->isValid();
303 303
     }
304 304
     
305
-   /**
306
-    * @return string[]
307
-    */
305
+    /**
306
+     * @return string[]
307
+     */
308 308
     abstract protected function getValidations() : array;
309 309
     
310 310
     protected function validateSyntax_params_empty() : void
@@ -465,12 +465,12 @@  discard block
 block discarded – undo
465 465
 
466 466
     abstract public function supportsURLEncoding() : bool;
467 467
     
468
-   /**
469
-    * Whether the command allows using logic keywords like "and:" or "or:"
470
-    * in the command parameters.
471
-    * 
472
-    * @return bool
473
-    */
468
+    /**
469
+     * Whether the command allows using logic keywords like "and:" or "or:"
470
+     * in the command parameters.
471
+     * 
472
+     * @return bool
473
+     */
474 474
     abstract public function supportsLogicKeywords() : bool;
475 475
     
476 476
     abstract public function generatesContent() : bool;
@@ -516,22 +516,22 @@  discard block
 block discarded – undo
516 516
         return $normalizer->normalize();
517 517
     }
518 518
     
519
-   /**
520
-    * Retrieves the names of all the command's supported types: the part
521
-    * between the command name and the colon. Example: {command type: params}.
522
-    * 
523
-    * @return string[]
524
-    */
519
+    /**
520
+     * Retrieves the names of all the command's supported types: the part
521
+     * between the command name and the colon. Example: {command type: params}.
522
+     * 
523
+     * @return string[]
524
+     */
525 525
     public function getSupportedTypes() : array
526 526
     {
527 527
         return array();
528 528
     }
529 529
     
530
-   /**
531
-    * Retrieves all variable names used in the command.
532
-    * 
533
-    * @return Mailcode_Variables_Collection_Regular
534
-    */
530
+    /**
531
+     * Retrieves all variable names used in the command.
532
+     * 
533
+     * @return Mailcode_Variables_Collection_Regular
534
+     */
535 535
     public function getVariables() : Mailcode_Variables_Collection_Regular
536 536
     {
537 537
         return Mailcode::create()->findVariables($this->paramsString);
@@ -556,26 +556,26 @@  discard block
 block discarded – undo
556 556
         );
557 557
     }
558 558
 
559
-   /**
560
-    * Sets a parameter for the translation backend. The backend can use
561
-    * these to allow command-specific configurations.
562
-    *
563
-    * @param string $name
564
-    * @param mixed $value
565
-    * @return $this
566
-    */
559
+    /**
560
+     * Sets a parameter for the translation backend. The backend can use
561
+     * these to allow command-specific configurations.
562
+     *
563
+     * @param string $name
564
+     * @param mixed $value
565
+     * @return $this
566
+     */
567 567
     public function setTranslationParam(string $name, $value)
568 568
     {
569 569
         $this->translationParams[$name] = $value;
570 570
         return $this;
571 571
     }
572 572
 
573
-   /**
574
-    * Retrieves a previously set translation parameter.
575
-    *
576
-    * @param string $name
577
-    * @return mixed
578
-    */
573
+    /**
574
+     * Retrieves a previously set translation parameter.
575
+     *
576
+     * @param string $name
577
+     * @return mixed
578
+     */
579 579
     public function getTranslationParam(string $name)
580 580
     {
581 581
         if(isset($this->translationParams[$name]))
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowDate.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
 {
23 23
     const VALIDATION_NOT_A_FORMAT_STRING = 55401;
24 24
     
25
-   /**
26
-    * The date format string.
27
-    * @var string
28
-    */
25
+    /**
26
+     * The date format string.
27
+     * @var string
28
+     */
29 29
     private $formatString;
30 30
     
31
-   /**
32
-    * @var Mailcode_Date_FormatInfo
33
-    */
31
+    /**
32
+     * @var Mailcode_Date_FormatInfo
33
+     */
34 34
     private $formatInfo;
35 35
 
36 36
     public function getName() : string
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
         );
91 91
     }
92 92
     
93
-   /**
94
-    * Retrieves the format string used to format the date.
95
-    * 
96
-    * @return string A PHP compatible date format string.
97
-    */
93
+    /**
94
+     * Retrieves the format string used to format the date.
95
+     * 
96
+     * @return string A PHP compatible date format string.
97
+     */
98 98
     public function getFormatString() : string
99 99
     {
100 100
         return $this->formatString;
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowNumber.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -31,15 +31,15 @@  discard block
 block discarded – undo
31 31
     const VALIDATION_INVALID_DECIMAL_SEPARATOR = 72209;
32 32
     const VALIDATION_SEPARATORS_SAME_CHARACTER = 72210;
33 33
     
34
-   /**
35
-    * The default number format string.
36
-    * @var string
37
-    */
34
+    /**
35
+     * The default number format string.
36
+     * @var string
37
+     */
38 38
     private $formatString = Mailcode_Number_Info::DEFAULT_FORMAT;
39 39
     
40
-   /**
41
-    * @var Mailcode_Date_FormatInfo
42
-    */
40
+    /**
41
+     * @var Mailcode_Date_FormatInfo
42
+     */
43 43
     private $formatInfo;
44 44
 
45 45
     public function getName() : string
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
 
64 64
     protected function validateSyntax_check_format() : void
65 65
     {
66
-         $tokens = $this->params->getInfo()->getStringLiterals();
66
+            $tokens = $this->params->getInfo()->getStringLiterals();
67 67
          
68
-         // no format specified? Use the default one.
69
-         if(empty($tokens))
70
-         {
71
-             return;
72
-         }
68
+            // no format specified? Use the default one.
69
+            if(empty($tokens))
70
+            {
71
+                return;
72
+            }
73 73
 
74
-         $token = array_pop($tokens);
75
-         $this->parseFormatString($token->getText());
74
+            $token = array_pop($tokens);
75
+            $this->parseFormatString($token->getText());
76 76
     }
77 77
 
78 78
     private function parseFormatString(string $format) : void
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
         );
92 92
     }
93 93
     
94
-   /**
95
-    * Retrieves the format string used to format the number.
96
-    * 
97
-    * @return string
98
-    */
94
+    /**
95
+     * Retrieves the format string used to format the number.
96
+     * 
97
+     * @return string
98
+     */
99 99
     public function getFormatString() : string
100 100
     {
101 101
         return $this->formatString;
Please login to merge, or discard this patch.