@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | { |
73 | 73 | $val = $this->validator->createStringLiteral(); |
74 | 74 | |
75 | - if($val->isValid()) |
|
75 | + if ($val->isValid()) |
|
76 | 76 | { |
77 | 77 | $this->sourceFormat = strtoupper($val->getToken()->getText()); |
78 | 78 | return; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | $countries = self::getSupportedCountries(); |
96 | 96 | |
97 | - if(isset($countries[$this->sourceFormat])) { |
|
97 | + if (isset($countries[$this->sourceFormat])) { |
|
98 | 98 | return; |
99 | 99 | } |
100 | 100 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public static function getSupportedCountries() : array |
115 | 115 | { |
116 | - if(self::$countriesLoaded) { |
|
116 | + if (self::$countriesLoaded) { |
|
117 | 117 | return self::$supportedCountries; |
118 | 118 | } |
119 | 119 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | $data = self::loadData(); |
123 | 123 | |
124 | - foreach($data as $code => $def) |
|
124 | + foreach ($data as $code => $def) |
|
125 | 125 | { |
126 | 126 | $code = (string)$code; |
127 | 127 | |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | $data = FileHelper::parseJSONFile(__DIR__.'/ShowPhone/numbers.json'); |
146 | 146 | $result = array(); |
147 | 147 | |
148 | - foreach($data as $idx => $def) |
|
148 | + foreach ($data as $idx => $def) |
|
149 | 149 | { |
150 | - if(!is_array($def) || !is_string($idx)) |
|
150 | + if (!is_array($def) || !is_string($idx)) |
|
151 | 151 | { |
152 | 152 | continue; |
153 | 153 | } |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | public const ERROR_CANNOT_MODIFY_FINALIZED = 52302; |
27 | 27 | public const ERROR_NO_VALIDATION_RESULT_AVAILABLE = 52303; |
28 | 28 | |
29 | - /** |
|
30 | - * @var Mailcode_Commands_Command[] |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var Mailcode_Commands_Command[] |
|
31 | + */ |
|
32 | 32 | protected array $commands = array(); |
33 | 33 | |
34 | 34 | /** |
@@ -63,21 +63,21 @@ discard block |
||
63 | 63 | return $this; |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
67 | - * Whether there are any commands in the collection. |
|
68 | - * |
|
69 | - * @return bool |
|
70 | - */ |
|
66 | + /** |
|
67 | + * Whether there are any commands in the collection. |
|
68 | + * |
|
69 | + * @return bool |
|
70 | + */ |
|
71 | 71 | public function hasCommands() : bool |
72 | 72 | { |
73 | 73 | return !empty($this->commands); |
74 | 74 | } |
75 | 75 | |
76 | - /** |
|
77 | - * Counts the amount of commands in the collection. |
|
78 | - * |
|
79 | - * @return int |
|
80 | - */ |
|
76 | + /** |
|
77 | + * Counts the amount of commands in the collection. |
|
78 | + * |
|
79 | + * @return int |
|
80 | + */ |
|
81 | 81 | public function countCommands() : int |
82 | 82 | { |
83 | 83 | return count($this->commands); |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | $this->commands = $keep; |
99 | 99 | } |
100 | 100 | |
101 | - /** |
|
102 | - * Retrieves all commands that were detected, in the exact order |
|
103 | - * they were found. |
|
104 | - * |
|
105 | - * @return Mailcode_Commands_Command[] |
|
106 | - */ |
|
101 | + /** |
|
102 | + * Retrieves all commands that were detected, in the exact order |
|
103 | + * they were found. |
|
104 | + * |
|
105 | + * @return Mailcode_Commands_Command[] |
|
106 | + */ |
|
107 | 107 | public function getCommands() : array |
108 | 108 | { |
109 | 109 | $this->validate(); |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
360 | - * Retrieves only show variable commands in the collection, if any. |
|
361 | - * |
|
362 | - * @return Mailcode_Commands_Command_ShowVariable[] |
|
363 | - */ |
|
360 | + * Retrieves only show variable commands in the collection, if any. |
|
361 | + * |
|
362 | + * @return Mailcode_Commands_Command_ShowVariable[] |
|
363 | + */ |
|
364 | 364 | public function getShowVariableCommands(): array |
365 | 365 | { |
366 | 366 | return Mailcode_Collection_TypeFilter::getShowVariableCommands($this->commands); |
@@ -374,11 +374,11 @@ discard block |
||
374 | 374 | return Mailcode_Collection_TypeFilter::getForCommands($this->commands); |
375 | 375 | } |
376 | 376 | |
377 | - /** |
|
378 | - * Retrieves only show date commands in the collection, if any. |
|
379 | - * |
|
380 | - * @return Mailcode_Commands_Command_ShowDate[] |
|
381 | - */ |
|
377 | + /** |
|
378 | + * Retrieves only show date commands in the collection, if any. |
|
379 | + * |
|
380 | + * @return Mailcode_Commands_Command_ShowDate[] |
|
381 | + */ |
|
382 | 382 | public function getShowDateCommands() : array |
383 | 383 | { |
384 | 384 | return Mailcode_Collection_TypeFilter::getShowDateCommands($this->commands); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function addCommand(Mailcode_Commands_Command $command) : Mailcode_Collection |
47 | 47 | { |
48 | - if($this->finalized) |
|
48 | + if ($this->finalized) |
|
49 | 49 | { |
50 | 50 | throw new Mailcode_Exception( |
51 | 51 | 'Cannot add commands to a finalized collection', |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | { |
88 | 88 | $keep = array(); |
89 | 89 | |
90 | - foreach($this->commands as $existing) |
|
90 | + foreach ($this->commands as $existing) |
|
91 | 91 | { |
92 | - if($existing !== $command) |
|
92 | + if ($existing !== $command) |
|
93 | 93 | { |
94 | 94 | $keep[] = $existing; |
95 | 95 | } |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | |
127 | 127 | $hashes = array(); |
128 | 128 | |
129 | - foreach($this->commands as $command) |
|
129 | + foreach ($this->commands as $command) |
|
130 | 130 | { |
131 | 131 | $hash = $command->getHash(); |
132 | 132 | |
133 | - if(!isset($hashes[$hash])) |
|
133 | + if (!isset($hashes[$hash])) |
|
134 | 134 | { |
135 | 135 | $hashes[$hash] = $command; |
136 | 136 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function addCommands(array $commands) : Mailcode_Collection |
150 | 150 | { |
151 | - foreach($commands as $command) |
|
151 | + foreach ($commands as $command) |
|
152 | 152 | { |
153 | 153 | $this->addCommand($command); |
154 | 154 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | $collection = new Mailcode_Variables_Collection_Regular(); |
173 | 173 | |
174 | - foreach($this->commands as $command) |
|
174 | + foreach ($this->commands as $command) |
|
175 | 175 | { |
176 | 176 | $collection->mergeWith($command->getVariables()); |
177 | 177 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | { |
212 | 212 | $this->validate(); |
213 | 213 | |
214 | - if(isset($this->validationResult)) |
|
214 | + if (isset($this->validationResult)) |
|
215 | 215 | { |
216 | 216 | return $this->validationResult; |
217 | 217 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | private function validate() : void |
227 | 227 | { |
228 | - if(isset($this->validationResult) || $this->validating) |
|
228 | + if (isset($this->validationResult) || $this->validating) |
|
229 | 229 | { |
230 | 230 | return; |
231 | 231 | } |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | { |
246 | 246 | $errors = $this->getErrors(); |
247 | 247 | |
248 | - foreach($errors as $error) |
|
248 | + foreach ($errors as $error) |
|
249 | 249 | { |
250 | - if($error->getCode() === $code) |
|
250 | + if ($error->getCode() === $code) |
|
251 | 251 | { |
252 | 252 | return true; |
253 | 253 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | $errors = $this->errors; |
284 | 284 | |
285 | - if(!$result->isValid()) |
|
285 | + if (!$result->isValid()) |
|
286 | 286 | { |
287 | 287 | $errors[] = new Mailcode_Collection_Error_Message( |
288 | 288 | '', |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | { |
299 | 299 | $errors = $this->getErrors(); |
300 | 300 | |
301 | - if(!empty($errors)) |
|
301 | + if (!empty($errors)) |
|
302 | 302 | { |
303 | 303 | return array_shift($errors); |
304 | 304 | } |
@@ -319,11 +319,11 @@ discard block |
||
319 | 319 | |
320 | 320 | private function validateNesting() : void |
321 | 321 | { |
322 | - foreach($this->commands as $command) |
|
322 | + foreach ($this->commands as $command) |
|
323 | 323 | { |
324 | 324 | $command->validateNesting(); |
325 | 325 | |
326 | - if(!$command->isValid()) { |
|
326 | + if (!$command->isValid()) { |
|
327 | 327 | $this->addInvalidCommand($command); |
328 | 328 | } |
329 | 329 | } |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | { |
401 | 401 | $commands = $this->getCommands(); |
402 | 402 | |
403 | - if(!empty($commands)) |
|
403 | + if (!empty($commands)) |
|
404 | 404 | { |
405 | 405 | return array_shift($commands); |
406 | 406 | } |
@@ -432,16 +432,16 @@ discard block |
||
432 | 432 | */ |
433 | 433 | private function pruneProtectedContentCommands() : void |
434 | 434 | { |
435 | - if(!$this->isValid()) |
|
435 | + if (!$this->isValid()) |
|
436 | 436 | { |
437 | 437 | return; |
438 | 438 | } |
439 | 439 | |
440 | 440 | $keep = array(); |
441 | 441 | |
442 | - foreach($this->commands as $command) |
|
442 | + foreach ($this->commands as $command) |
|
443 | 443 | { |
444 | - if(!$command->hasContentParent()) |
|
444 | + if (!$command->hasContentParent()) |
|
445 | 445 | { |
446 | 446 | $keep[] = $command; |
447 | 447 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $errors = $this->getErrors(); |
459 | 459 | $result = array(); |
460 | 460 | |
461 | - foreach($errors as $error) |
|
461 | + foreach ($errors as $error) |
|
462 | 462 | { |
463 | 463 | $result[] = $error->getCode(); |
464 | 464 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | public const VALIDATION_NAME_NOHTML = 'nohtml'; |
10 | 10 | |
11 | - public function setHTMLEnabled(bool $enabled=true) : self; |
|
11 | + public function setHTMLEnabled(bool $enabled = true) : self; |
|
12 | 12 | |
13 | 13 | public function isHTMLEnabled() : bool; |
14 | 14 |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function getParser() : Mailcode_Parser |
79 | 79 | { |
80 | - if(!isset($this->parser)) |
|
80 | + if (!isset($this->parser)) |
|
81 | 81 | { |
82 | 82 | $this->parser = new Mailcode_Parser($this); |
83 | 83 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getCommands() : Mailcode_Commands |
95 | 95 | { |
96 | - if(!isset($this->commands)) |
|
96 | + if (!isset($this->commands)) |
|
97 | 97 | { |
98 | 98 | $this->commands = new Mailcode_Commands(); |
99 | 99 | } |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | * @param Mailcode_Commands_Command|null $sourceCommand |
119 | 119 | * @return Mailcode_Variables_Collection_Regular |
120 | 120 | */ |
121 | - public function findVariables(string $subject, ?Mailcode_Commands_Command $sourceCommand=null) : Mailcode_Variables_Collection_Regular |
|
121 | + public function findVariables(string $subject, ?Mailcode_Commands_Command $sourceCommand = null) : Mailcode_Variables_Collection_Regular |
|
122 | 122 | { |
123 | 123 | return $this->createVariables()->parseString($subject, $sourceCommand); |
124 | 124 | } |
125 | 125 | |
126 | 126 | public function createVariables() : Mailcode_Variables |
127 | 127 | { |
128 | - if(!isset($this->variables)) |
|
128 | + if (!isset($this->variables)) |
|
129 | 129 | { |
130 | 130 | $this->variables = new Mailcode_Variables(); |
131 | 131 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function createTranslator() : Mailcode_Translator |
143 | 143 | { |
144 | - if(!isset($this->translator)) |
|
144 | + if (!isset($this->translator)) |
|
145 | 145 | { |
146 | 146 | $this->translator = new Mailcode_Translator(); |
147 | 147 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | return self::$logger; |
190 | 190 | } |
191 | 191 | |
192 | - public static function setDebugging(bool $enabled=true) : void |
|
192 | + public static function setDebugging(bool $enabled = true) : void |
|
193 | 193 | { |
194 | 194 | self::$debug = $enabled; |
195 | 195 | } |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | * @param array<string|int,mixed> $context |
205 | 205 | * @return void |
206 | 206 | */ |
207 | - public static function debug(string $message, array $context=array()) : void |
|
207 | + public static function debug(string $message, array $context = array()) : void |
|
208 | 208 | { |
209 | - if(self::$debug && isset(self::$logger)) |
|
209 | + if (self::$debug && isset(self::$logger)) |
|
210 | 210 | { |
211 | 211 | self::$logger->debug($message, $context); |
212 | 212 | } |
@@ -31,29 +31,29 @@ discard block |
||
31 | 31 | public const PACKAGE_NAME = 'Mailcode'; |
32 | 32 | |
33 | 33 | /** |
34 | - * @var Mailcode_Parser|NULL |
|
35 | - */ |
|
34 | + * @var Mailcode_Parser|NULL |
|
35 | + */ |
|
36 | 36 | protected $parser = null; |
37 | 37 | |
38 | - /** |
|
39 | - * @var Mailcode_Commands|NULL |
|
40 | - */ |
|
38 | + /** |
|
39 | + * @var Mailcode_Commands|NULL |
|
40 | + */ |
|
41 | 41 | protected $commands = null; |
42 | 42 | |
43 | - /** |
|
44 | - * @var Mailcode_Variables|NULL |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var Mailcode_Variables|NULL |
|
45 | + */ |
|
46 | 46 | protected $variables = null; |
47 | 47 | |
48 | - /** |
|
49 | - * @var Mailcode_Translator|NULL |
|
50 | - */ |
|
48 | + /** |
|
49 | + * @var Mailcode_Translator|NULL |
|
50 | + */ |
|
51 | 51 | protected $translator = null; |
52 | 52 | |
53 | - /** |
|
54 | - * Creates a new mailcode instance. |
|
55 | - * @return Mailcode |
|
56 | - */ |
|
53 | + /** |
|
54 | + * Creates a new mailcode instance. |
|
55 | + * @return Mailcode |
|
56 | + */ |
|
57 | 57 | public static function create() : Mailcode |
58 | 58 | { |
59 | 59 | return new Mailcode(); |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | - * Parses the string to detect all commands contained within. |
|
69 | - * |
|
70 | - * @param string $string |
|
71 | - * @return Mailcode_Collection |
|
72 | - */ |
|
68 | + * Parses the string to detect all commands contained within. |
|
69 | + * |
|
70 | + * @param string $string |
|
71 | + * @return Mailcode_Collection |
|
72 | + */ |
|
73 | 73 | public function parseString(string $string) : Mailcode_Collection |
74 | 74 | { |
75 | 75 | return $this->getParser() |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | ->getCollection(); |
78 | 78 | } |
79 | 79 | |
80 | - /** |
|
81 | - * Retrieves the string parser instance used to detect commands. |
|
82 | - * |
|
83 | - * @return Mailcode_Parser |
|
84 | - */ |
|
80 | + /** |
|
81 | + * Retrieves the string parser instance used to detect commands. |
|
82 | + * |
|
83 | + * @return Mailcode_Parser |
|
84 | + */ |
|
85 | 85 | public function getParser() : Mailcode_Parser |
86 | 86 | { |
87 | 87 | if(!isset($this->parser)) |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | return $this->parser; |
93 | 93 | } |
94 | 94 | |
95 | - /** |
|
96 | - * Retrieves the commands collection, which is used to |
|
97 | - * access information on the available commands. |
|
98 | - * |
|
99 | - * @return Mailcode_Commands |
|
100 | - */ |
|
95 | + /** |
|
96 | + * Retrieves the commands collection, which is used to |
|
97 | + * access information on the available commands. |
|
98 | + * |
|
99 | + * @return Mailcode_Commands |
|
100 | + */ |
|
101 | 101 | public function getCommands() : Mailcode_Commands |
102 | 102 | { |
103 | 103 | if(!isset($this->commands)) |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | return $this->variables; |
141 | 141 | } |
142 | 142 | |
143 | - /** |
|
144 | - * Creates the translator, which can be used to convert commands |
|
145 | - * to another supported syntax. |
|
146 | - * |
|
147 | - * @return Mailcode_Translator |
|
148 | - */ |
|
143 | + /** |
|
144 | + * Creates the translator, which can be used to convert commands |
|
145 | + * to another supported syntax. |
|
146 | + * |
|
147 | + * @return Mailcode_Translator |
|
148 | + */ |
|
149 | 149 | public function createTranslator() : Mailcode_Translator |
150 | 150 | { |
151 | 151 | if(!isset($this->translator)) |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | return $this->translator; |
157 | 157 | } |
158 | 158 | |
159 | - /** |
|
160 | - * Creates the styler, which can be used to retrieve the |
|
161 | - * CSS required to style the highlighted commands in HTML. |
|
162 | - * |
|
163 | - * @return Mailcode_Styler |
|
164 | - */ |
|
159 | + /** |
|
160 | + * Creates the styler, which can be used to retrieve the |
|
161 | + * CSS required to style the highlighted commands in HTML. |
|
162 | + * |
|
163 | + * @return Mailcode_Styler |
|
164 | + */ |
|
165 | 165 | public function createStyler() : Mailcode_Styler |
166 | 166 | { |
167 | 167 | return new Mailcode_Styler(); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $instanceID = $command->getInstanceID(); |
50 | 50 | |
51 | - if(isset(self::$generated[$instanceID])) |
|
51 | + if (isset(self::$generated[$instanceID])) |
|
52 | 52 | { |
53 | 53 | return self::$generated[$instanceID]; |
54 | 54 | } |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | |
86 | 86 | private static function generateIDString(TrackingIDInterface $command) : string |
87 | 87 | { |
88 | - if(isset(self::$customGenerator)) |
|
88 | + if (isset(self::$customGenerator)) |
|
89 | 89 | { |
90 | 90 | $result = call_user_func(self::$customGenerator, $command); |
91 | 91 | |
92 | - if(is_string($result)) |
|
92 | + if (is_string($result)) |
|
93 | 93 | { |
94 | 94 | return $result; |
95 | 95 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public static function getContent(int $id) : string |
118 | 118 | { |
119 | - if(isset(self::$contents[$id])) |
|
119 | + if (isset(self::$contents[$id])) |
|
120 | 120 | { |
121 | 121 | return self::$contents[$id]; |
122 | 122 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public static function clearContent(int $id) : void |
141 | 141 | { |
142 | - if(isset(self::$contents[$id])) |
|
142 | + if (isset(self::$contents[$id])) |
|
143 | 143 | { |
144 | 144 | unset(self::$contents[$id]); |
145 | 145 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function parse() : self |
158 | 158 | { |
159 | - if($this->parsed) |
|
159 | + if ($this->parsed) |
|
160 | 160 | { |
161 | 161 | return $this; |
162 | 162 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $this->detectCommands(); |
168 | 168 | |
169 | - foreach($this->commands as $commandDef) |
|
169 | + foreach ($this->commands as $commandDef) |
|
170 | 170 | { |
171 | 171 | $this->processCommand($commandDef); |
172 | 172 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $commands = Mailcode::create()->getCommands()->getContentCommands(); |
188 | 188 | $result = array(); |
189 | 189 | |
190 | - foreach($commands as $command) |
|
190 | + foreach ($commands as $command) |
|
191 | 191 | { |
192 | 192 | $result[] = $command->getName(); |
193 | 193 | } |
@@ -260,9 +260,9 @@ discard block |
||
260 | 260 | |
261 | 261 | private function validateCommandContents() : void |
262 | 262 | { |
263 | - foreach($this->commands as $command) |
|
263 | + foreach ($this->commands as $command) |
|
264 | 264 | { |
265 | - if(!$command->validateContent($this, $this->collection)) |
|
265 | + if (!$command->validateContent($this, $this->collection)) |
|
266 | 266 | { |
267 | 267 | return; |
268 | 268 | } |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | $openingCommands = $this->detectOpeningCommands(); |
275 | 275 | $closingCommands = $this->detectClosingCommands(); |
276 | 276 | |
277 | - if(!$this->validateCommandsList($openingCommands, $closingCommands)) |
|
277 | + if (!$this->validateCommandsList($openingCommands, $closingCommands)) |
|
278 | 278 | { |
279 | 279 | return; |
280 | 280 | } |
281 | 281 | |
282 | - foreach($openingCommands as $idx => $def) |
|
282 | + foreach ($openingCommands as $idx => $def) |
|
283 | 283 | { |
284 | 284 | $this->commands[] = new CommandDef( |
285 | 285 | $def['name'], |
@@ -300,20 +300,20 @@ discard block |
||
300 | 300 | $opening = count($openingCommands); |
301 | 301 | $closing = count($closingCommands); |
302 | 302 | $max = $opening; |
303 | - if($closing > $max) { |
|
303 | + if ($closing > $max) { |
|
304 | 304 | $max = $closing; |
305 | 305 | } |
306 | 306 | |
307 | - for($i=0; $i < $max; $i++) |
|
307 | + for ($i = 0; $i < $max; $i++) |
|
308 | 308 | { |
309 | 309 | // command closed that was never opened |
310 | - if(!isset($openingCommands[$i])) |
|
310 | + if (!isset($openingCommands[$i])) |
|
311 | 311 | { |
312 | 312 | return $this->addErrorClosedNeverOpened($closingCommands[$i]['matchedText']); |
313 | 313 | } |
314 | 314 | |
315 | 315 | // command opened that was never closed |
316 | - if(!isset($closingCommands[$i])) |
|
316 | + if (!isset($closingCommands[$i])) |
|
317 | 317 | { |
318 | 318 | return $this->addErrorNeverClosed( |
319 | 319 | $openingCommands[$i]['matchedText'], |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | } |
323 | 323 | |
324 | 324 | // command closed does not match opening |
325 | - if($openingCommands[$i]['name'] !== $closingCommands[$i]['name']) |
|
325 | + if ($openingCommands[$i]['name'] !== $closingCommands[$i]['name']) |
|
326 | 326 | { |
327 | 327 | return $this->addErrorClosingMismatch( |
328 | 328 | $openingCommands[$i]['name'], |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | |
378 | 378 | $result = array(); |
379 | 379 | |
380 | - foreach($matches[0] as $idx => $matchedText) |
|
380 | + foreach ($matches[0] as $idx => $matchedText) |
|
381 | 381 | { |
382 | 382 | $result[] = array( |
383 | 383 | 'name' => strtolower(trim((string)$matches[1][$idx])), |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | $matchedText, |
462 | 462 | t( |
463 | 463 | 'The command is never closed with a matching %1$s command.', |
464 | - sb()->code('{' . $name . '}') |
|
464 | + sb()->code('{'.$name.'}') |
|
465 | 465 | ), |
466 | 466 | Mailcode_Commands_CommonConstants::VALIDATION_MISSING_CONTENT_CLOSING_TAG |
467 | 467 | ); |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | ) |
486 | 486 | ->t( |
487 | 487 | 'It must be closed with a matching %1$s command.', |
488 | - sb()->code('{' . $name . '}') |
|
488 | + sb()->code('{'.$name.'}') |
|
489 | 489 | ), |
490 | 490 | Mailcode_Commands_CommonConstants::VALIDATION_CONTENT_CLOSING_MISMATCHED_TAG |
491 | 491 | ); |
@@ -30,22 +30,22 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function debugOpeningCommands(array $matches) : void |
32 | 32 | { |
33 | - if(!Mailcode::isDebugEnabled()) |
|
33 | + if (!Mailcode::isDebugEnabled()) |
|
34 | 34 | { |
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | Mailcode::debug('Opening command matches:'); |
39 | 39 | |
40 | - if(empty($matches)) |
|
40 | + if (empty($matches)) |
|
41 | 41 | { |
42 | 42 | Mailcode::debug('...None found.'); |
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | - foreach($matches[0] as $idx => $matchedText) |
|
46 | + foreach ($matches[0] as $idx => $matchedText) |
|
47 | 47 | { |
48 | - $number = $idx+1; |
|
48 | + $number = $idx + 1; |
|
49 | 49 | |
50 | 50 | Mailcode::debug(sprintf('...#%02d matched: [%s]', $number, $matchedText)); |
51 | 51 | Mailcode::debug(sprintf('...#%02d name...: [%s]', $number, $matches[1][$idx])); |
@@ -59,22 +59,22 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function debugClosingCommands(array $commands) : void |
61 | 61 | { |
62 | - if(!Mailcode::isDebugEnabled()) |
|
62 | + if (!Mailcode::isDebugEnabled()) |
|
63 | 63 | { |
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
67 | 67 | Mailcode::debug('Closing command matches:', $commands); |
68 | 68 | |
69 | - if(empty($commands)) |
|
69 | + if (empty($commands)) |
|
70 | 70 | { |
71 | 71 | Mailcode::debug('...None found.'); |
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | - foreach($commands as $idx => $command) |
|
75 | + foreach ($commands as $idx => $command) |
|
76 | 76 | { |
77 | - $number = $idx+1; |
|
77 | + $number = $idx + 1; |
|
78 | 78 | |
79 | 79 | Mailcode::debug(sprintf('...#%02d matched: [%s]', $number, $command['matchedText'])); |
80 | 80 | Mailcode::debug(sprintf('...#%02d name...: [%s]', $number, $command['name'])); |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | |
84 | 84 | public function debugCommandDef(CommandDef $commandDef) : void |
85 | 85 | { |
86 | - if(!Mailcode::isDebugEnabled()) |
|
86 | + if (!Mailcode::isDebugEnabled()) |
|
87 | 87 | { |
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
91 | 91 | Mailcode::debug('Command definition:', $commandDef->toArray()); |
92 | 92 | |
93 | - if(defined('TESTS_ROOT')) |
|
93 | + if (defined('TESTS_ROOT')) |
|
94 | 94 | { |
95 | 95 | print_r($commandDef->toArray()); |
96 | 96 | } |
@@ -23,24 +23,24 @@ |
||
23 | 23 | */ |
24 | 24 | class Mailcode_Parser_Match |
25 | 25 | { |
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | 29 | protected string $name; |
30 | 30 | |
31 | - /** |
|
32 | - * @var string |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var string |
|
33 | + */ |
|
34 | 34 | protected string $type; |
35 | 35 | |
36 | - /** |
|
37 | - * @var string |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @var string |
|
38 | + */ |
|
39 | 39 | protected string $params; |
40 | 40 | |
41 | - /** |
|
42 | - * @var string |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var string |
|
43 | + */ |
|
44 | 44 | protected string $matchedString; |
45 | 45 | |
46 | 46 | public function __construct(string $name, string $type, string $params, string $matchedString) |
@@ -58,24 +58,24 @@ discard block |
||
58 | 58 | private function analyzeURL(string $url) : void |
59 | 59 | { |
60 | 60 | // Ignore phone URLs |
61 | - if(stripos($url, 'tel:') !== false) |
|
61 | + if (stripos($url, 'tel:') !== false) |
|
62 | 62 | { |
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | 66 | $placeholders = $this->safeguard->getPlaceholdersCollection()->getAll(); |
67 | 67 | |
68 | - foreach($placeholders as $placeholder) |
|
68 | + foreach ($placeholders as $placeholder) |
|
69 | 69 | { |
70 | 70 | $command = $placeholder->getCommand(); |
71 | 71 | |
72 | 72 | // The URL is not found in the replacement text |
73 | - if(strpos($url, $placeholder->getReplacementText()) === false) |
|
73 | + if (strpos($url, $placeholder->getReplacementText()) === false) |
|
74 | 74 | { |
75 | 75 | continue; |
76 | 76 | } |
77 | 77 | |
78 | - if($command instanceof URLEncodingInterface) |
|
78 | + if ($command instanceof URLEncodingInterface) |
|
79 | 79 | { |
80 | 80 | $this->applyEncoding($command); |
81 | 81 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | private function applyEncoding(URLEncodingInterface $command) : void |
86 | 86 | { |
87 | - if(!$command->isURLDecoded()) |
|
87 | + if (!$command->isURLDecoded()) |
|
88 | 88 | { |
89 | 89 | $command->setURLEncoding(); |
90 | 90 | } |