@@ -25,7 +25,7 @@ |
||
25 | 25 | $varName = ltrim($command->getVariableName(), '$'); |
26 | 26 | |
27 | 27 | // Automatically URL escape the variable if it's in an URL. |
28 | - if($command->isURLEncoded()) |
|
28 | + if ($command->isURLEncoded()) |
|
29 | 29 | { |
30 | 30 | return sprintf( |
31 | 31 | '${esc.url($%s)}', |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | $varName = ltrim($command->getVariableName(), '$'); |
57 | 57 | $javaFormat = $this->translateFormat($command->getFormatString()); |
58 | 58 | |
59 | - if(empty($internalFormat)) |
|
59 | + if (empty($internalFormat)) |
|
60 | 60 | { |
61 | 61 | $internalFormat = self::DEFAULT_INTERNAL_FORMAT; |
62 | 62 | } |
63 | 63 | |
64 | - if($command->isURLEncoded()) |
|
64 | + if ($command->isURLEncoded()) |
|
65 | 65 | { |
66 | 66 | return sprintf( |
67 | 67 | '${esc.url($date.format("%s", $date.toDate("%s", $%s)))}', |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | $chars = ConvertHelper::string2array($formatString); |
85 | 85 | $result = array(); |
86 | 86 | |
87 | - foreach($chars as $char) |
|
87 | + foreach ($chars as $char) |
|
88 | 88 | { |
89 | - if(!isset($this->charTable[$char])) |
|
89 | + if (!isset($this->charTable[$char])) |
|
90 | 90 | { |
91 | 91 | throw new Mailcode_Translator_Exception( |
92 | 92 | 'Unknown date format string character', |
@@ -29,7 +29,7 @@ |
||
29 | 29 | { |
30 | 30 | $varName = ltrim($command->getVariableName(), '$'); |
31 | 31 | |
32 | - if($command->isURLEncoded()) |
|
32 | + if ($command->isURLEncoded()) |
|
33 | 33 | { |
34 | 34 | return sprintf( |
35 | 35 | '${esc.url($%s.replaceAll($esc.newline, "<br/>"))}', |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $locale |
41 | 41 | ); |
42 | 42 | |
43 | - if($command->isURLEncoded()) |
|
43 | + if ($command->isURLEncoded()) |
|
44 | 44 | { |
45 | 45 | return sprintf( |
46 | 46 | '${esc.url($%s)}', |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $dc = '_'; |
93 | 93 | } |
94 | 94 | |
95 | - $type = $th . $dc; |
|
95 | + $type = $th.$dc; |
|
96 | 96 | |
97 | 97 | if (isset($this->typeLocales[$type])) { |
98 | 98 | return $this->typeLocales[$type]; |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | { |
106 | 106 | $result = '#'; |
107 | 107 | |
108 | - if($format->hasThousandsSeparator()) |
|
108 | + if ($format->hasThousandsSeparator()) |
|
109 | 109 | { |
110 | 110 | $result = '#,###'; |
111 | 111 | } |
112 | 112 | |
113 | - if($format->hasDecimals()) |
|
113 | + if ($format->hasDecimals()) |
|
114 | 114 | { |
115 | 115 | $result .= '.'.str_repeat('#', $format->getDecimals()); |
116 | 116 | } |
@@ -23,17 +23,17 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param string $formatString A date format string, or empty string for default. |
48 | 48 | * @return Mailcode_Commands_Command_ShowDate |
49 | 49 | */ |
50 | - public static function showDate(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowDate |
|
50 | + public static function showDate(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowDate |
|
51 | 51 | { |
52 | 52 | return self::$commandSets->show()->showDate($variableName, $formatString); |
53 | 53 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param string $formatString A number format string, or empty string for default. |
61 | 61 | * @return Mailcode_Commands_Command_ShowNumber |
62 | 62 | */ |
63 | - public static function showNumber(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowNumber |
|
63 | + public static function showNumber(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowNumber |
|
64 | 64 | { |
65 | 65 | return self::$commandSets->show()->showNumber($variableName, $formatString); |
66 | 66 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
89 | 89 | */ |
90 | - public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable |
|
90 | + public static function setVar(string $variableName, string $value, bool $quoteValue = true) : Mailcode_Commands_Command_SetVariable |
|
91 | 91 | { |
92 | 92 | return self::$commandSets->set()->setVar($variableName, $value, $quoteValue); |
93 | 93 | } |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | return self::$commandSets->if()->end(); |
121 | 121 | } |
122 | 122 | |
123 | - public static function if(string $condition, string $type='') : Mailcode_Commands_Command_If |
|
123 | + public static function if (string $condition, string $type = '') : Mailcode_Commands_Command_If |
|
124 | 124 | { |
125 | 125 | return self::$commandSets->if()->if($condition, $type); |
126 | 126 | } |
127 | 127 | |
128 | - public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable |
|
128 | + public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable |
|
129 | 129 | { |
130 | 130 | return self::$commandSets->if()->ifVar($variable, $operand, $value, $quoteValue); |
131 | 131 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | return self::$commandSets->if()->ifVarString($variable, $operand, $value); |
136 | 136 | } |
137 | 137 | |
138 | - public static function ifVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable |
|
138 | + public static function ifVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable |
|
139 | 139 | { |
140 | 140 | return self::$commandSets->if()->ifVarEquals($variable, $value, $quoteValue); |
141 | 141 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | return self::$commandSets->if()->ifVarEqualsString($variable, $value); |
146 | 146 | } |
147 | 147 | |
148 | - public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable |
|
148 | + public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable |
|
149 | 149 | { |
150 | 150 | return self::$commandSets->if()->ifVarNotEquals($variable, $value, $quoteValue); |
151 | 151 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | return self::$commandSets->if()->ifVarNotEqualsString($variable, $value); |
156 | 156 | } |
157 | 157 | |
158 | - public static function elseIf(string $condition, string $type='') : Mailcode_Commands_Command_ElseIf |
|
158 | + public static function elseIf (string $condition, string $type = '') : Mailcode_Commands_Command_ElseIf |
|
159 | 159 | { |
160 | 160 | return self::$commandSets->elseIf()->elseIf($condition, $type); |
161 | 161 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | return self::$commandSets->elseIf()->elseIfNotEmpty($variable); |
171 | 171 | } |
172 | 172 | |
173 | - public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable |
|
173 | + public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable |
|
174 | 174 | { |
175 | 175 | return self::$commandSets->elseIf()->elseIfVar($variable, $operand, $value, $quoteValue); |
176 | 176 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | return self::$commandSets->elseIf()->elseIfVarString($variable, $operand, $value); |
181 | 181 | } |
182 | 182 | |
183 | - public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable |
|
183 | + public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable |
|
184 | 184 | { |
185 | 185 | return self::$commandSets->elseIf()->elseIfVarEquals($variable, $value, $quoteValue); |
186 | 186 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | return self::$commandSets->elseIf()->elseIfVarEqualsString($variable, $value); |
191 | 191 | } |
192 | 192 | |
193 | - public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable |
|
193 | + public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable |
|
194 | 194 | { |
195 | 195 | return self::$commandSets->elseIf()->elseIfVarNotEquals($variable, $value, $quoteValue); |
196 | 196 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | return self::$commandSets->elseIf()->elseIfVarNotEqualsString($variable, $value); |
201 | 201 | } |
202 | 202 | |
203 | - public static function ifBeginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_BeginsWith |
|
203 | + public static function ifBeginsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_BeginsWith |
|
204 | 204 | { |
205 | 205 | return self::$commandSets->if()->ifBeginsWith($variable, $search, $caseInsensitive); |
206 | 206 | } |
@@ -220,22 +220,22 @@ discard block |
||
220 | 220 | return self::$commandSets->if()->ifVarEqualsNumber($variable, $number); |
221 | 221 | } |
222 | 222 | |
223 | - public static function ifEndsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_EndsWith |
|
223 | + public static function ifEndsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_EndsWith |
|
224 | 224 | { |
225 | 225 | return self::$commandSets->if()->ifEndsWith($variable, $search, $caseInsensitive); |
226 | 226 | } |
227 | 227 | |
228 | - public static function elseIfBeginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_BeginsWith |
|
228 | + public static function elseIfBeginsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_BeginsWith |
|
229 | 229 | { |
230 | 230 | return self::$commandSets->elseIf()->elseIfBeginsWith($variable, $search, $caseInsensitive); |
231 | 231 | } |
232 | 232 | |
233 | - public static function elseIfEndsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_EndsWith |
|
233 | + public static function elseIfEndsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_EndsWith |
|
234 | 234 | { |
235 | 235 | return self::$commandSets->elseIf()->elseIfEndsWith($variable, $search, $caseInsensitive); |
236 | 236 | } |
237 | 237 | |
238 | - public static function ifContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains |
|
238 | + public static function ifContains(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_Contains |
|
239 | 239 | { |
240 | 240 | return self::$commandSets->if()->ifContains($variable, array($search), $caseInsensitive); |
241 | 241 | } |
@@ -263,12 +263,12 @@ discard block |
||
263 | 263 | * @param bool $caseInsensitive |
264 | 264 | * @return Mailcode_Commands_Command_If_Contains |
265 | 265 | */ |
266 | - public static function ifContainsAny(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains |
|
266 | + public static function ifContainsAny(string $variable, array $searchTerms, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_Contains |
|
267 | 267 | { |
268 | 268 | return self::$commandSets->if()->ifContains($variable, $searchTerms, $caseInsensitive); |
269 | 269 | } |
270 | 270 | |
271 | - public static function elseIfContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains |
|
271 | + public static function elseIfContains(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_Contains |
|
272 | 272 | { |
273 | 273 | return self::$commandSets->elseIf()->elseIfContains($variable, array($search), $caseInsensitive); |
274 | 274 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @param bool $caseInsensitive |
282 | 282 | * @return Mailcode_Commands_Command_ElseIf_Contains |
283 | 283 | */ |
284 | - public static function elseIfContainsAny(string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains |
|
284 | + public static function elseIfContainsAny(string $variable, array $searchTerms, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_Contains |
|
285 | 285 | { |
286 | 286 | return self::$commandSets->elseIf()->elseIfContains($variable, $searchTerms, $caseInsensitive); |
287 | 287 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | return self::$commandSets->if()->ifNotEmpty($variable); |
297 | 297 | } |
298 | 298 | |
299 | - public static function for(string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For |
|
299 | + public static function for (string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For |
|
300 | 300 | { |
301 | 301 | return self::$commandSets->misc()->for($sourceVariable, $loopVariable); |
302 | 302 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | |
337 | 337 | public static function init() : void |
338 | 338 | { |
339 | - if(!isset(self::$commandSets)) |
|
339 | + if (!isset(self::$commandSets)) |
|
340 | 340 | { |
341 | 341 | self::$commandSets = new Mailcode_Factory_CommandSets(); |
342 | 342 | } |
@@ -24,9 +24,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $operand = $this->getOperandByIndex(1); |
49 | 49 | $value = $this->getTokenByIndex(2); |
50 | 50 | |
51 | - if($variable && $operand && $value && $operand->isAssignment()) |
|
51 | + if ($variable && $operand && $value && $operand->isAssignment()) |
|
52 | 52 | { |
53 | 53 | return true; |
54 | 54 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $operand = $this->getOperandByIndex(1); |
68 | 68 | $value = $this->getTokenByIndex(2); |
69 | 69 | |
70 | - if($variable && $operand && $value && $operand->isComparator()) |
|
70 | + if ($variable && $operand && $value && $operand->isComparator()) |
|
71 | 71 | { |
72 | 72 | return true; |
73 | 73 | } |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | { |
85 | 85 | $result = array(); |
86 | 86 | |
87 | - foreach($this->tokens as $token) |
|
87 | + foreach ($this->tokens as $token) |
|
88 | 88 | { |
89 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
|
89 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
|
90 | 90 | { |
91 | 91 | $result[] = $token->getVariable(); |
92 | 92 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | $token = $this->getTokenByIndex($index); |
109 | 109 | |
110 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
|
110 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
|
111 | 111 | { |
112 | 112 | return $token; |
113 | 113 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | { |
128 | 128 | $token = $this->getTokenByIndex($index); |
129 | 129 | |
130 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
130 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
131 | 131 | { |
132 | 132 | return $token; |
133 | 133 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | { |
148 | 148 | $token = $this->getTokenByIndex($index); |
149 | 149 | |
150 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
150 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
151 | 151 | { |
152 | 152 | return $token; |
153 | 153 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | { |
168 | 168 | $token = $this->getTokenByIndex($index); |
169 | 169 | |
170 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
170 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
171 | 171 | { |
172 | 172 | return $token; |
173 | 173 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function getTokenByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token |
187 | 187 | { |
188 | - if(isset($this->tokens[$index])) |
|
188 | + if (isset($this->tokens[$index])) |
|
189 | 189 | { |
190 | 190 | return $this->tokens[$index]; |
191 | 191 | } |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | { |
216 | 216 | $result = array(); |
217 | 217 | |
218 | - foreach($this->tokens as $token) |
|
218 | + foreach ($this->tokens as $token) |
|
219 | 219 | { |
220 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
220 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
221 | 221 | { |
222 | 222 | $result[] = $token; |
223 | 223 | } |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | { |
239 | 239 | $result = array(); |
240 | 240 | |
241 | - foreach($this->tokens as $token) |
|
241 | + foreach ($this->tokens as $token) |
|
242 | 242 | { |
243 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
243 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
244 | 244 | { |
245 | 245 | $result[] = $token; |
246 | 246 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | |
256 | 256 | foreach ($keywords as $keyword) |
257 | 257 | { |
258 | - if($keyword->isURLEncoded()) |
|
258 | + if ($keyword->isURLEncoded()) |
|
259 | 259 | { |
260 | 260 | return true; |
261 | 261 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | public function addURLEncoding() : Mailcode_Parser_Statement_Info |
285 | 285 | { |
286 | - if(!$this->hasURLEncoding()) |
|
286 | + if (!$this->hasURLEncoding()) |
|
287 | 287 | { |
288 | 288 | $this->tokenizer->appendKeyword('urlencode'); |
289 | 289 | $this->tokens = $this->tokenizer->getTokens(); |
@@ -24,9 +24,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | { |
139 | 139 | $result = array(); |
140 | 140 | |
141 | - foreach($this->tokensOrdered as $token) |
|
141 | + foreach ($this->tokensOrdered as $token) |
|
142 | 142 | { |
143 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
143 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
144 | 144 | { |
145 | 145 | $result[] = $token; |
146 | 146 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | { |
154 | 154 | $unknown = $this->getUnknown(); |
155 | 155 | |
156 | - if(!empty($unknown)) |
|
156 | + if (!empty($unknown)) |
|
157 | 157 | { |
158 | 158 | return array_shift($unknown); |
159 | 159 | } |
@@ -165,11 +165,11 @@ discard block |
||
165 | 165 | { |
166 | 166 | $parts = array(); |
167 | 167 | |
168 | - foreach($this->tokensOrdered as $token) |
|
168 | + foreach ($this->tokensOrdered as $token) |
|
169 | 169 | { |
170 | 170 | $string = $token->getNormalized(); |
171 | 171 | |
172 | - if($string != '') |
|
172 | + if ($string != '') |
|
173 | 173 | { |
174 | 174 | $parts[] = $string; |
175 | 175 | } |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | { |
183 | 183 | $this->tokenized = trim($statement); |
184 | 184 | |
185 | - foreach($this->tokenCategories as $token) |
|
185 | + foreach ($this->tokenCategories as $token) |
|
186 | 186 | { |
187 | 187 | $method = 'tokenize_'.$token; |
188 | 188 | |
189 | - if(!method_exists($this, $method)) |
|
189 | + if (!method_exists($this, $method)) |
|
190 | 190 | { |
191 | 191 | throw new Mailcode_Exception( |
192 | 192 | 'Unknown statement token.', |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | * @param string $matchedText |
211 | 211 | * @param mixed $subject |
212 | 212 | */ |
213 | - protected function registerToken(string $type, string $matchedText, $subject=null) : void |
|
213 | + protected function registerToken(string $type, string $matchedText, $subject = null) : void |
|
214 | 214 | { |
215 | 215 | $this->tokensTemporary[] = $this->createToken($type, $matchedText, $subject); |
216 | 216 | } |
217 | 217 | |
218 | - protected function createToken(string $type, string $matchedText, $subject=null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
218 | + protected function createToken(string $type, string $matchedText, $subject = null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
219 | 219 | { |
220 | 220 | $tokenID = $this->generateID(); |
221 | 221 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | $token = $this->appendToken('Keyword', $name); |
238 | 238 | |
239 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
239 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
240 | 240 | { |
241 | 241 | return $token; |
242 | 242 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | |
256 | 256 | foreach ($this->tokensOrdered as $checkToken) |
257 | 257 | { |
258 | - if($checkToken->getID() !== $tokenID) |
|
258 | + if ($checkToken->getID() !== $tokenID) |
|
259 | 259 | { |
260 | 260 | $keep[] = $checkToken; |
261 | 261 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | return $this; |
267 | 267 | } |
268 | 268 | |
269 | - protected function appendToken(string $type, string $matchedText, $subject=null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
269 | + protected function appendToken(string $type, string $matchedText, $subject = null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
270 | 270 | { |
271 | 271 | $token = $this->createToken($type, $matchedText, $subject); |
272 | 272 | |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | |
278 | 278 | protected function getTokenByID(string $tokenID) : ?Mailcode_Parser_Statement_Tokenizer_Token |
279 | 279 | { |
280 | - foreach($this->tokensTemporary as $token) |
|
280 | + foreach ($this->tokensTemporary as $token) |
|
281 | 281 | { |
282 | - if($token->getID() === $tokenID) |
|
282 | + if ($token->getID() === $tokenID) |
|
283 | 283 | { |
284 | 284 | return $token; |
285 | 285 | } |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | |
306 | 306 | protected function tokenize_keywords() : void |
307 | 307 | { |
308 | - foreach($this->keywords as $keyword) |
|
308 | + foreach ($this->keywords as $keyword) |
|
309 | 309 | { |
310 | - if(strstr($this->tokenized, $keyword)) |
|
310 | + if (strstr($this->tokenized, $keyword)) |
|
311 | 311 | { |
312 | 312 | $this->registerToken('Keyword', $keyword); |
313 | 313 | } |
@@ -321,12 +321,12 @@ discard block |
||
321 | 321 | // over that could not be tokenized. |
322 | 322 | $parts = \AppUtils\ConvertHelper::explodeTrim($this->delimiter, $this->tokenized); |
323 | 323 | |
324 | - foreach($parts as $part) |
|
324 | + foreach ($parts as $part) |
|
325 | 325 | { |
326 | 326 | $token = $this->getTokenByID($part); |
327 | 327 | |
328 | 328 | // if the entry is a token, simply add it. |
329 | - if($token) |
|
329 | + if ($token) |
|
330 | 330 | { |
331 | 331 | $this->tokensOrdered[] = $token; |
332 | 332 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | { |
343 | 343 | $vars = Mailcode::create()->findVariables($this->tokenized)->getGroupedByHash(); |
344 | 344 | |
345 | - foreach($vars as $var) |
|
345 | + foreach ($vars as $var) |
|
346 | 346 | { |
347 | 347 | $this->registerToken('Variable', $var->getMatchedText(), $var); |
348 | 348 | } |
@@ -350,9 +350,9 @@ discard block |
||
350 | 350 | |
351 | 351 | protected function tokenize_operands() : void |
352 | 352 | { |
353 | - foreach($this->operands as $operand) |
|
353 | + foreach ($this->operands as $operand) |
|
354 | 354 | { |
355 | - if(strstr($this->tokenized, $operand)) |
|
355 | + if (strstr($this->tokenized, $operand)) |
|
356 | 356 | { |
357 | 357 | $this->registerToken('Operand', $operand); |
358 | 358 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $matches = array(); |
365 | 365 | preg_match_all('/"(.*)"/sxU', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
366 | 366 | |
367 | - foreach($matches[0] as $match) |
|
367 | + foreach ($matches[0] as $match) |
|
368 | 368 | { |
369 | 369 | $this->registerToken('StringLiteral', $match); |
370 | 370 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $matches = array(); |
376 | 376 | preg_match_all('/-*[0-9]+\s*[.,]\s*[0-9]+|-*[0-9]+/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
377 | 377 | |
378 | - foreach($matches[0] as $match) |
|
378 | + foreach ($matches[0] as $match) |
|
379 | 379 | { |
380 | 380 | $this->registerToken('Number', $match); |
381 | 381 | } |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | { |
393 | 393 | static $alphas; |
394 | 394 | |
395 | - if(!isset($alphas)) |
|
395 | + if (!isset($alphas)) |
|
396 | 396 | { |
397 | 397 | $alphas = range('A', 'Z'); |
398 | 398 | } |
@@ -401,12 +401,12 @@ discard block |
||
401 | 401 | |
402 | 402 | $result = ''; |
403 | 403 | |
404 | - for($i=0; $i < $amount; $i++) |
|
404 | + for ($i = 0; $i < $amount; $i++) |
|
405 | 405 | { |
406 | 406 | $result .= $alphas[array_rand($alphas)]; |
407 | 407 | } |
408 | 408 | |
409 | - if(!in_array($result, self::$ids)) |
|
409 | + if (!in_array($result, self::$ids)) |
|
410 | 410 | { |
411 | 411 | self::$ids[] = $result; |
412 | 412 | return $result; |
@@ -55,50 +55,50 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard |
130 | 130 | { |
131 | - if(empty($delimiter)) |
|
131 | + if (empty($delimiter)) |
|
132 | 132 | { |
133 | 133 | throw new Mailcode_Exception( |
134 | 134 | 'Empty delimiter', |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $placeholders = $this->getPlaceholders(); |
179 | 179 | $string = $this->originalString; |
180 | 180 | |
181 | - foreach($placeholders as $placeholder) |
|
181 | + foreach ($placeholders as $placeholder) |
|
182 | 182 | { |
183 | 183 | $string = $this->makePlaceholderSafe($string, $placeholder); |
184 | 184 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | { |
193 | 193 | $pos = mb_strpos($string, $placeholder->getOriginalText()); |
194 | 194 | |
195 | - if($pos === false) |
|
195 | + if ($pos === false) |
|
196 | 196 | { |
197 | 197 | throw new Mailcode_Exception( |
198 | 198 | 'Placeholder original text not found', |
@@ -221,18 +221,18 @@ discard block |
||
221 | 221 | $urls = ConvertHelper::createURLFinder($string)->getURLs(); |
222 | 222 | $placeholders = $this->getPlaceholders(); |
223 | 223 | |
224 | - foreach($urls as $url) |
|
224 | + foreach ($urls as $url) |
|
225 | 225 | { |
226 | - foreach($placeholders as $placeholder) |
|
226 | + foreach ($placeholders as $placeholder) |
|
227 | 227 | { |
228 | 228 | $command = $placeholder->getCommand(); |
229 | 229 | |
230 | - if(!$command->supportsURLEncoding()) |
|
230 | + if (!$command->supportsURLEncoding()) |
|
231 | 231 | { |
232 | 232 | continue; |
233 | 233 | } |
234 | 234 | |
235 | - if(strstr($url, $placeholder->getReplacementText())) |
|
235 | + if (strstr($url, $placeholder->getReplacementText())) |
|
236 | 236 | { |
237 | 237 | $command->setURLEncoding(true); |
238 | 238 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting |
251 | 251 | { |
252 | - if(is_string($subject)) |
|
252 | + if (is_string($subject)) |
|
253 | 253 | { |
254 | 254 | $subject = Mailcode::create()->createString($subject); |
255 | 255 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function getPlaceholders() |
267 | 267 | { |
268 | - if(isset($this->placeholders)) |
|
268 | + if (isset($this->placeholders)) |
|
269 | 269 | { |
270 | 270 | return $this->placeholders; |
271 | 271 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | |
275 | 275 | $cmds = $this->getCollection()->getCommands(); |
276 | 276 | |
277 | - foreach($cmds as $command) |
|
277 | + foreach ($cmds as $command) |
|
278 | 278 | { |
279 | 279 | self::$counter++; |
280 | 280 | |
@@ -288,21 +288,21 @@ discard block |
||
288 | 288 | return $this->placeholders; |
289 | 289 | } |
290 | 290 | |
291 | - protected function restore(string $string, bool $partial=false, bool $highlighted=false) : string |
|
291 | + protected function restore(string $string, bool $partial = false, bool $highlighted = false) : string |
|
292 | 292 | { |
293 | - if(!$partial) |
|
293 | + if (!$partial) |
|
294 | 294 | { |
295 | 295 | $this->requireValidCollection(); |
296 | 296 | } |
297 | 297 | |
298 | 298 | $formatting = $this->createFormatting($string); |
299 | 299 | |
300 | - if($partial) |
|
300 | + if ($partial) |
|
301 | 301 | { |
302 | 302 | $formatting->makePartial(); |
303 | 303 | } |
304 | 304 | |
305 | - if($highlighted) |
|
305 | + if ($highlighted) |
|
306 | 306 | { |
307 | 307 | $formatting->replaceWithHTMLHighlighting(); |
308 | 308 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | */ |
399 | 399 | public function getCollection() : Mailcode_Collection |
400 | 400 | { |
401 | - if(isset($this->collection)) |
|
401 | + if (isset($this->collection)) |
|
402 | 402 | { |
403 | 403 | return $this->collection; |
404 | 404 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | */ |
421 | 421 | protected function requireValidCollection() : void |
422 | 422 | { |
423 | - if($this->getCollection()->isValid()) |
|
423 | + if ($this->getCollection()->isValid()) |
|
424 | 424 | { |
425 | 425 | return; |
426 | 426 | } |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | */ |
444 | 444 | public function getPlaceholderStrings() : array |
445 | 445 | { |
446 | - if(is_array($this->placeholderStrings)) |
|
446 | + if (is_array($this->placeholderStrings)) |
|
447 | 447 | { |
448 | 448 | return $this->placeholderStrings; |
449 | 449 | } |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | |
453 | 453 | $this->placeholderStrings = array(); |
454 | 454 | |
455 | - foreach($placeholders as $placeholder) |
|
455 | + foreach ($placeholders as $placeholder) |
|
456 | 456 | { |
457 | 457 | $this->placeholderStrings[] = $placeholder->getReplacementText(); |
458 | 458 | } |
@@ -478,9 +478,9 @@ discard block |
||
478 | 478 | { |
479 | 479 | $placeholders = $this->getPlaceholders(); |
480 | 480 | |
481 | - foreach($placeholders as $placeholder) |
|
481 | + foreach ($placeholders as $placeholder) |
|
482 | 482 | { |
483 | - if($placeholder->getID() === $id) |
|
483 | + if ($placeholder->getID() === $id) |
|
484 | 484 | { |
485 | 485 | return $placeholder; |
486 | 486 | } |
@@ -507,9 +507,9 @@ discard block |
||
507 | 507 | { |
508 | 508 | $placeholders = $this->getPlaceholders(); |
509 | 509 | |
510 | - foreach($placeholders as $placeholder) |
|
510 | + foreach ($placeholders as $placeholder) |
|
511 | 511 | { |
512 | - if($placeholder->getReplacementText() === $string) |
|
512 | + if ($placeholder->getReplacementText() === $string) |
|
513 | 513 | { |
514 | 514 | return $placeholder; |
515 | 515 | } |