@@ -27,19 +27,19 @@ discard block |
||
27 | 27 | { |
28 | 28 | const ERROR_INVALID_LOCATION_INSTANCE = 65601; |
29 | 29 | |
30 | - /** |
|
31 | - * @var Mailcode_Parser_Safeguard_Formatting |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var Mailcode_Parser_Safeguard_Formatting |
|
32 | + */ |
|
33 | 33 | protected $formatting; |
34 | 34 | |
35 | - /** |
|
36 | - * @var Mailcode_StringContainer |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var Mailcode_StringContainer |
|
37 | + */ |
|
38 | 38 | protected $subject; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string[] |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var string[] |
|
42 | + */ |
|
43 | 43 | protected $log = array(); |
44 | 44 | |
45 | 45 | public function __construct(Mailcode_Parser_Safeguard_Formatting $formatting) |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | ); |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Retrieves all formatter-specific placeholder locations |
|
98 | - * in the subject string. |
|
99 | - * |
|
100 | - * @return Mailcode_Parser_Safeguard_Formatter_Location[] |
|
101 | - */ |
|
96 | + /** |
|
97 | + * Retrieves all formatter-specific placeholder locations |
|
98 | + * in the subject string. |
|
99 | + * |
|
100 | + * @return Mailcode_Parser_Safeguard_Formatter_Location[] |
|
101 | + */ |
|
102 | 102 | protected function resolveLocations() : array |
103 | 103 | { |
104 | 104 | $placeholders = $this->formatting->getSafeguard()->getPlaceholders(); |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | return $result; |
114 | 114 | } |
115 | 115 | |
116 | - /** |
|
117 | - * Resolves the newline character used in the string. |
|
118 | - * |
|
119 | - * @param string $subject |
|
120 | - * @return string |
|
121 | - */ |
|
116 | + /** |
|
117 | + * Resolves the newline character used in the string. |
|
118 | + * |
|
119 | + * @param string $subject |
|
120 | + * @return string |
|
121 | + */ |
|
122 | 122 | protected function resolveNewlineChar(string $subject) : string |
123 | 123 | { |
124 | 124 | $eol = ConvertHelper::detectEOLCharacter($subject); |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | ); |
151 | 151 | } |
152 | 152 | |
153 | - /** |
|
154 | - * @return string[] |
|
155 | - */ |
|
153 | + /** |
|
154 | + * @return string[] |
|
155 | + */ |
|
156 | 156 | public function getLog() : array |
157 | 157 | { |
158 | 158 | return $this->log; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | $instance = new $class($this, $placeholder); |
79 | 79 | |
80 | - if($instance instanceof Mailcode_Parser_Safeguard_Formatter_Location) |
|
80 | + if ($instance instanceof Mailcode_Parser_Safeguard_Formatter_Location) |
|
81 | 81 | { |
82 | 82 | return $instance; |
83 | 83 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | $result = array(); |
107 | 107 | |
108 | - foreach($placeholders as $placeholder) |
|
108 | + foreach ($placeholders as $placeholder) |
|
109 | 109 | { |
110 | 110 | $result[] = $this->createLocation($placeholder); |
111 | 111 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | { |
124 | 124 | $eol = ConvertHelper::detectEOLCharacter($subject); |
125 | 125 | |
126 | - if($eol) |
|
126 | + if ($eol) |
|
127 | 127 | { |
128 | 128 | $this->log(sprintf( |
129 | 129 | 'Detected EOL character: %s.', |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | */ |
24 | 24 | trait Mailcode_Traits_Formatting_HTMLHighlighting |
25 | 25 | { |
26 | - /** |
|
27 | - * @var string[] |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var string[] |
|
28 | + */ |
|
29 | 29 | private $excludeTags = array( |
30 | 30 | 'style', // NOTE: style tags are excluded natively on the parser level. |
31 | 31 | 'script' |
32 | 32 | ); |
33 | 33 | |
34 | - /** |
|
35 | - * Adds an HTML tag name to the list of tags within which |
|
36 | - * commands may not be highlighted. |
|
37 | - * |
|
38 | - * @param string $tagName Case insensitive. |
|
39 | - * @return $this |
|
40 | - */ |
|
34 | + /** |
|
35 | + * Adds an HTML tag name to the list of tags within which |
|
36 | + * commands may not be highlighted. |
|
37 | + * |
|
38 | + * @param string $tagName Case insensitive. |
|
39 | + * @return $this |
|
40 | + */ |
|
41 | 41 | public function excludeTag(string $tagName) |
42 | 42 | { |
43 | 43 | $tagName = strtolower($tagName); |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | return $this; |
51 | 51 | } |
52 | 52 | |
53 | - /** |
|
54 | - * Adds several exluded tag names at once. |
|
55 | - * |
|
56 | - * @param string[] $tagNames |
|
57 | - * @return $this |
|
58 | - */ |
|
53 | + /** |
|
54 | + * Adds several exluded tag names at once. |
|
55 | + * |
|
56 | + * @param string[] $tagNames |
|
57 | + * @return $this |
|
58 | + */ |
|
59 | 59 | public function excludeTags(array $tagNames) |
60 | 60 | { |
61 | 61 | foreach($tagNames as $tagName) |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | return $this; |
67 | 67 | } |
68 | 68 | |
69 | - /** |
|
70 | - * Whether the specified tag name is in the exlusion list. |
|
71 | - * |
|
72 | - * @param string $tagName |
|
73 | - * @return bool |
|
74 | - */ |
|
69 | + /** |
|
70 | + * Whether the specified tag name is in the exlusion list. |
|
71 | + * |
|
72 | + * @param string $tagName |
|
73 | + * @return bool |
|
74 | + */ |
|
75 | 75 | public function isTagExcluded(string $tagName) : bool |
76 | 76 | { |
77 | 77 | $tagName = strtolower($tagName); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | $tagName = strtolower($tagName); |
44 | 44 | |
45 | - if(!in_array($tagName, $this->excludeTags)) |
|
45 | + if (!in_array($tagName, $this->excludeTags)) |
|
46 | 46 | { |
47 | 47 | $this->excludeTags[] = $tagName; |
48 | 48 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function excludeTags(array $tagNames) |
60 | 60 | { |
61 | - foreach($tagNames as $tagName) |
|
61 | + foreach ($tagNames as $tagName) |
|
62 | 62 | { |
63 | 63 | $this->excludeTag((string)$tagName); |
64 | 64 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | $errors = $this->errors; |
101 | 101 | |
102 | - if(!$result->isValid()) |
|
102 | + if (!$result->isValid()) |
|
103 | 103 | { |
104 | 104 | $errors[] = new Mailcode_Collection_Error_Message( |
105 | 105 | '', |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | { |
116 | 116 | $errors = $this->getErrors(); |
117 | 117 | |
118 | - if(!empty($errors)) |
|
118 | + if (!empty($errors)) |
|
119 | 119 | { |
120 | 120 | return array_shift($errors); |
121 | 121 | } |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | { |
158 | 158 | $hashes = array(); |
159 | 159 | |
160 | - foreach($this->commands as $command) |
|
160 | + foreach ($this->commands as $command) |
|
161 | 161 | { |
162 | 162 | $hash = $command->getHash(); |
163 | 163 | |
164 | - if(!isset($hashes[$hash])) |
|
164 | + if (!isset($hashes[$hash])) |
|
165 | 165 | { |
166 | 166 | $hashes[$hash] = $command; |
167 | 167 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function addCommands(array $commands) : Mailcode_Collection |
180 | 180 | { |
181 | - foreach($commands as $command) |
|
181 | + foreach ($commands as $command) |
|
182 | 182 | { |
183 | 183 | $this->addCommand($command); |
184 | 184 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | { |
198 | 198 | $collection = new Mailcode_Variables_Collection_Regular(); |
199 | 199 | |
200 | - foreach($this->commands as $command) |
|
200 | + foreach ($this->commands as $command) |
|
201 | 201 | { |
202 | 202 | $collection->mergeWith($command->getVariables()); |
203 | 203 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | public function getValidationResult() : OperationResult |
209 | 209 | { |
210 | - if($this->validationResult instanceof OperationResult) |
|
210 | + if ($this->validationResult instanceof OperationResult) |
|
211 | 211 | { |
212 | 212 | return $this->validationResult; |
213 | 213 | } |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | { |
224 | 224 | $errors = $this->getErrors(); |
225 | 225 | |
226 | - foreach($errors as $error) |
|
226 | + foreach ($errors as $error) |
|
227 | 227 | { |
228 | - if($error->getCode() === $code) |
|
228 | + if ($error->getCode() === $code) |
|
229 | 229 | { |
230 | 230 | return true; |
231 | 231 | } |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | { |
263 | 263 | $result = array(); |
264 | 264 | |
265 | - foreach($this->commands as $command) |
|
265 | + foreach ($this->commands as $command) |
|
266 | 266 | { |
267 | - if($command instanceof $className) |
|
267 | + if ($command instanceof $className) |
|
268 | 268 | { |
269 | 269 | $result[] = $command; |
270 | 270 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | { |
278 | 278 | $commands = $this->getCommands(); |
279 | 279 | |
280 | - if(!empty($commands)) |
|
280 | + if (!empty($commands)) |
|
281 | 281 | { |
282 | 282 | return array_shift($commands); |
283 | 283 | } |
@@ -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); |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | '{\s*([a-z]+)\s+([a-z-]+)\s*:([^}]*)}' |
29 | 29 | ); |
30 | 30 | |
31 | - /** |
|
32 | - * @var Mailcode |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var Mailcode |
|
33 | + */ |
|
34 | 34 | protected $mailcode; |
35 | 35 | |
36 | - /** |
|
37 | - * @var Mailcode_Commands |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @var Mailcode_Commands |
|
38 | + */ |
|
39 | 39 | protected $commands; |
40 | 40 | |
41 | 41 | /** |
@@ -49,24 +49,24 @@ discard block |
||
49 | 49 | $this->commands = $this->mailcode->getCommands(); |
50 | 50 | } |
51 | 51 | |
52 | - /** |
|
53 | - * Gets the regex format string used to detect commands. |
|
54 | - * |
|
55 | - * @return string |
|
56 | - */ |
|
52 | + /** |
|
53 | + * Gets the regex format string used to detect commands. |
|
54 | + * |
|
55 | + * @return string |
|
56 | + */ |
|
57 | 57 | protected static function getRegex() : string |
58 | 58 | { |
59 | 59 | return '/'.implode('|', self::COMMAND_REGEX_PARTS).'/sixU'; |
60 | 60 | } |
61 | 61 | |
62 | - /** |
|
63 | - * Parses a string to detect all commands within. Returns a |
|
64 | - * collection instance that contains information on all the |
|
65 | - * commands. |
|
66 | - * |
|
67 | - * @param string $string |
|
68 | - * @return Mailcode_Collection A collection with all unique commands found. |
|
69 | - */ |
|
62 | + /** |
|
63 | + * Parses a string to detect all commands within. Returns a |
|
64 | + * collection instance that contains information on all the |
|
65 | + * commands. |
|
66 | + * |
|
67 | + * @param string $string |
|
68 | + * @return Mailcode_Collection A collection with all unique commands found. |
|
69 | + */ |
|
70 | 70 | public function parseString(string $string) : Mailcode_Collection |
71 | 71 | { |
72 | 72 | $collection = new Mailcode_Collection(); |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | return preg_replace('%<style\b[^>]*>(.*?)</style>%six', '', $subject); |
100 | 100 | } |
101 | 101 | |
102 | - /** |
|
103 | - * Processes a single match found in the string: creates the command, |
|
104 | - * and adds it to the collection if it's a valid command, or to the list |
|
105 | - * of invalid commands otherwise. |
|
106 | - * |
|
107 | - * @param Mailcode_Parser_Match $match |
|
108 | - * @param Mailcode_Collection $collection |
|
109 | - */ |
|
102 | + /** |
|
103 | + * Processes a single match found in the string: creates the command, |
|
104 | + * and adds it to the collection if it's a valid command, or to the list |
|
105 | + * of invalid commands otherwise. |
|
106 | + * |
|
107 | + * @param Mailcode_Parser_Match $match |
|
108 | + * @param Mailcode_Collection $collection |
|
109 | + */ |
|
110 | 110 | protected function processMatch(Mailcode_Parser_Match $match, Mailcode_Collection $collection) : void |
111 | 111 | { |
112 | 112 | $name = $match->getName(); |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | - /** |
|
157 | - * Parses a single regex match: determines which named group |
|
158 | - * matches, and retrieves the according information. |
|
159 | - * |
|
160 | - * @param array[] $matches The regex results array. |
|
161 | - * @param int $index The matched index. |
|
162 | - * @return Mailcode_Parser_Match |
|
163 | - */ |
|
156 | + /** |
|
157 | + * Parses a single regex match: determines which named group |
|
158 | + * matches, and retrieves the according information. |
|
159 | + * |
|
160 | + * @param array[] $matches The regex results array. |
|
161 | + * @param int $index The matched index. |
|
162 | + * @return Mailcode_Parser_Match |
|
163 | + */ |
|
164 | 164 | protected function parseMatch(array $matches, int $index) : Mailcode_Parser_Match |
165 | 165 | { |
166 | 166 | $name = ''; // the command name, e.g. "showvar" |
@@ -198,26 +198,26 @@ discard block |
||
198 | 198 | ); |
199 | 199 | } |
200 | 200 | |
201 | - /** |
|
202 | - * Creates an instance of the safeguard tool, which |
|
203 | - * is used to safeguard commands in a string with placeholders. |
|
204 | - * |
|
205 | - * @param string $subject The string to use to safeguard commands in. |
|
206 | - * @return Mailcode_Parser_Safeguard |
|
207 | - * @see Mailcode_Parser_Safeguard |
|
208 | - */ |
|
201 | + /** |
|
202 | + * Creates an instance of the safeguard tool, which |
|
203 | + * is used to safeguard commands in a string with placeholders. |
|
204 | + * |
|
205 | + * @param string $subject The string to use to safeguard commands in. |
|
206 | + * @return Mailcode_Parser_Safeguard |
|
207 | + * @see Mailcode_Parser_Safeguard |
|
208 | + */ |
|
209 | 209 | public function createSafeguard(string $subject) : Mailcode_Parser_Safeguard |
210 | 210 | { |
211 | 211 | return new Mailcode_Parser_Safeguard($this, $subject); |
212 | 212 | } |
213 | 213 | |
214 | - /** |
|
215 | - * Creates a statement parser, which is used to validate arbitrary |
|
216 | - * command statements. |
|
217 | - * |
|
218 | - * @param string $statement |
|
219 | - * @return Mailcode_Parser_Statement |
|
220 | - */ |
|
214 | + /** |
|
215 | + * Creates a statement parser, which is used to validate arbitrary |
|
216 | + * command statements. |
|
217 | + * |
|
218 | + * @param string $statement |
|
219 | + * @return Mailcode_Parser_Statement |
|
220 | + */ |
|
221 | 221 | public function createStatement(string $statement) : Mailcode_Parser_Statement |
222 | 222 | { |
223 | 223 | return new Mailcode_Parser_Statement($statement); |
@@ -146,8 +146,7 @@ discard block |
||
146 | 146 | if($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
147 | 147 | { |
148 | 148 | $this->stack[] = $cmd; |
149 | - } |
|
150 | - else if($cmd instanceof Mailcode_Commands_Command_Type_Closing) |
|
149 | + } else if($cmd instanceof Mailcode_Commands_Command_Type_Closing) |
|
151 | 150 | { |
152 | 151 | array_pop($this->stack); |
153 | 152 | } |
@@ -177,13 +176,11 @@ discard block |
||
177 | 176 | if(!empty($matches[1][$index])) |
178 | 177 | { |
179 | 178 | $name = $matches[1][$index]; |
180 | - } |
|
181 | - else if(!empty($matches[2][$index])) |
|
179 | + } else if(!empty($matches[2][$index])) |
|
182 | 180 | { |
183 | 181 | $name = $matches[2][$index]; |
184 | 182 | $params = $matches[3][$index]; |
185 | - } |
|
186 | - else if(!empty($matches[4][$index])) |
|
183 | + } else if(!empty($matches[4][$index])) |
|
187 | 184 | { |
188 | 185 | $name = $matches[4][$index]; |
189 | 186 | $type = $matches[5][$index]; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $total = count($matches[0]); |
80 | 80 | |
81 | - for($i=0; $i < $total; $i++) |
|
81 | + for ($i = 0; $i < $total; $i++) |
|
82 | 82 | { |
83 | 83 | $match = $this->parseMatch($matches, $i); |
84 | 84 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | protected function prepareString(string $subject) : string |
92 | 92 | { |
93 | - if(!ConvertHelper::isStringHTML($subject)) |
|
93 | + if (!ConvertHelper::isStringHTML($subject)) |
|
94 | 94 | { |
95 | 95 | return $subject; |
96 | 96 | } |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | private function handleNesting(Mailcode_Commands_Command $cmd) : void |
141 | 141 | { |
142 | 142 | // Set the command's parent from the stack, if any is present. |
143 | - if(!empty($this->stack)) |
|
143 | + if (!empty($this->stack)) |
|
144 | 144 | { |
145 | 145 | $cmd->setParent($this->stack[array_key_last($this->stack)]); |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Handle opening and closing commands, adding and removing from the stack. |
149 | - if($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
|
149 | + if ($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
|
150 | 150 | { |
151 | 151 | $this->stack[] = $cmd; |
152 | 152 | } |
153 | - else if($cmd instanceof Mailcode_Commands_Command_Type_Closing) |
|
153 | + else if ($cmd instanceof Mailcode_Commands_Command_Type_Closing) |
|
154 | 154 | { |
155 | 155 | array_pop($this->stack); |
156 | 156 | } |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | // 5 = parameter type command, type |
178 | 178 | // 6 = parameter type command, params |
179 | 179 | |
180 | - if(!empty($matches[1][$index])) |
|
180 | + if (!empty($matches[1][$index])) |
|
181 | 181 | { |
182 | 182 | $name = $matches[1][$index]; |
183 | 183 | } |
184 | - else if(!empty($matches[2][$index])) |
|
184 | + else if (!empty($matches[2][$index])) |
|
185 | 185 | { |
186 | 186 | $name = $matches[2][$index]; |
187 | 187 | $params = $matches[3][$index]; |
188 | 188 | } |
189 | - else if(!empty($matches[4][$index])) |
|
189 | + else if (!empty($matches[4][$index])) |
|
190 | 190 | { |
191 | 191 | $name = $matches[4][$index]; |
192 | 192 | $type = $matches[5][$index]; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | public function setTemplate(string $template) : Mailcode_Parser_Safeguard_Formatter_Type_MarkVariables |
62 | 62 | { |
63 | - if(substr_count($template, '%s') !== 1) |
|
63 | + if (substr_count($template, '%s') !== 1) |
|
64 | 64 | { |
65 | 65 | throw new Mailcode_Exception( |
66 | 66 | 'Invalid tag template', |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $parts = explode('%s', $this->getTemplate()); |
102 | 102 | $tag = array_shift($parts); |
103 | 103 | |
104 | - if($this->templateMode === self::TEMPLATE_MODE_INLINE) |
|
104 | + if ($this->templateMode === self::TEMPLATE_MODE_INLINE) |
|
105 | 105 | { |
106 | 106 | $tag = str_replace('__STYLES__', $this->getInlineStyles(), $tag); |
107 | 107 | } |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | $styles = ''; |
130 | 130 | $regex = '/\.'.self::DEFAULT_CLASS_NAME.'{([^}]+)}/'; |
131 | 131 | |
132 | - if(preg_match($regex, $this->getCSS(), $matches)) |
|
132 | + if (preg_match($regex, $this->getCSS(), $matches)) |
|
133 | 133 | { |
134 | 134 | $styles = $matches[1]; |
135 | 135 | } |
136 | 136 | |
137 | - if(empty($styles)) |
|
137 | + if (empty($styles)) |
|
138 | 138 | { |
139 | 139 | throw new Mailcode_Exception( |
140 | 140 | 'Cannot extract styles.', |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $file = MAILCODE_INSTALL_FOLDER.'/css/marked-variables.css'; |
192 | 192 | $path = realpath($file); |
193 | 193 | |
194 | - if($path !== false) |
|
194 | + if ($path !== false) |
|
195 | 195 | { |
196 | 196 | return $path; |
197 | 197 | } |
@@ -24,15 +24,15 @@ |
||
24 | 24 | { |
25 | 25 | const ERROR_UNKNOWN_DATE_FORMAT_CHARACTER = 55501; |
26 | 26 | |
27 | - /** |
|
28 | - * The date format used in the date variable. This is used to convert |
|
29 | - * the native date to the format specified in the variable command. |
|
30 | - */ |
|
27 | + /** |
|
28 | + * The date format used in the date variable. This is used to convert |
|
29 | + * the native date to the format specified in the variable command. |
|
30 | + */ |
|
31 | 31 | const DEFAULT_INTERNAL_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"; |
32 | 32 | |
33 | - /** |
|
34 | - * @var string[]string |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var string[]string |
|
35 | + */ |
|
36 | 36 | private $charTable = array( |
37 | 37 | 'd' => 'dd', |
38 | 38 | 'j' => 'd', |
@@ -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', |
@@ -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)}', |
@@ -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 | } |