@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | public const ERROR_INVALID_DUMMY_COMMAND_TYPE = 45903; |
29 | 29 | public const ERROR_INVALID_COMMAND_CLASS = 45904; |
30 | 30 | |
31 | - /** |
|
32 | - * @var Mailcode_Commands_Command[] |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var Mailcode_Commands_Command[] |
|
33 | + */ |
|
34 | 34 | private array $commands = array(); |
35 | 35 | |
36 | - /** |
|
37 | - * @var array<string,Mailcode_Commands_Command> |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @var array<string,Mailcode_Commands_Command> |
|
38 | + */ |
|
39 | 39 | private static array $dummyCommands = array(); |
40 | 40 | |
41 | - /** |
|
42 | - * Retrieves a list of all available command IDs. |
|
43 | - * |
|
44 | - * @return string[] |
|
45 | - */ |
|
41 | + /** |
|
42 | + * Retrieves a list of all available command IDs. |
|
43 | + * |
|
44 | + * @return string[] |
|
45 | + */ |
|
46 | 46 | public function getIDs() : array |
47 | 47 | { |
48 | 48 | static $ids = array(); |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | return $result; |
89 | 89 | } |
90 | 90 | |
91 | - /** |
|
92 | - * Gets an available command by its ID. |
|
93 | - * |
|
94 | - * @param string $id |
|
95 | - * @return Mailcode_Commands_Command |
|
96 | - */ |
|
91 | + /** |
|
92 | + * Gets an available command by its ID. |
|
93 | + * |
|
94 | + * @param string $id |
|
95 | + * @return Mailcode_Commands_Command |
|
96 | + */ |
|
97 | 97 | public function getByID(string $id) : Mailcode_Commands_Command |
98 | 98 | { |
99 | 99 | static $instances = array(); |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | return $instances[$id]; |
107 | 107 | } |
108 | 108 | |
109 | - /** |
|
110 | - * Retrieves the ID of a command by its name. |
|
111 | - * |
|
112 | - * @param string $name |
|
113 | - * @throws Mailcode_Exception |
|
114 | - * @return string |
|
115 | - * |
|
116 | - * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST |
|
117 | - */ |
|
109 | + /** |
|
110 | + * Retrieves the ID of a command by its name. |
|
111 | + * |
|
112 | + * @param string $name |
|
113 | + * @throws Mailcode_Exception |
|
114 | + * @return string |
|
115 | + * |
|
116 | + * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST |
|
117 | + */ |
|
118 | 118 | public function getIDByName(string $name) : string |
119 | 119 | { |
120 | 120 | $items = $this->getAll(); |
@@ -225,14 +225,14 @@ discard block |
||
225 | 225 | return $class; |
226 | 226 | } |
227 | 227 | |
228 | - /** |
|
229 | - * Translates the command type to the expected class naming scheme. |
|
230 | - * |
|
231 | - * Example: not-empty => NotEmpty |
|
232 | - * |
|
233 | - * @param string $type |
|
234 | - * @return string |
|
235 | - */ |
|
228 | + /** |
|
229 | + * Translates the command type to the expected class naming scheme. |
|
230 | + * |
|
231 | + * Example: not-empty => NotEmpty |
|
232 | + * |
|
233 | + * @param string $type |
|
234 | + * @return string |
|
235 | + */ |
|
236 | 236 | private function adjustTypeName(string $type) : string |
237 | 237 | { |
238 | 238 | $type = str_replace('-', ' ', $type); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | static $ids = array(); |
49 | 49 | |
50 | - if(empty($ids)) { |
|
50 | + if (empty($ids)) { |
|
51 | 51 | $ids = FileHelper::createFileFinder(__DIR__.'/Commands/Command') |
52 | 52 | ->getPHPClassNames(); |
53 | 53 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function getAll() : array |
67 | 67 | { |
68 | - if(!empty($this->commands)) { |
|
68 | + if (!empty($this->commands)) { |
|
69 | 69 | return $this->commands; |
70 | 70 | } |
71 | 71 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | $result = array(); |
75 | 75 | |
76 | - foreach($ids as $id) |
|
76 | + foreach ($ids as $id) |
|
77 | 77 | { |
78 | 78 | $result[] = $this->getDummyCommand($id); |
79 | 79 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | static $instances = array(); |
100 | 100 | |
101 | - if(!isset($instances[$id])) |
|
101 | + if (!isset($instances[$id])) |
|
102 | 102 | { |
103 | 103 | $instances[$id] = $this->createCommand($id, '__dummy', '', ''); |
104 | 104 | } |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | { |
120 | 120 | $items = $this->getAll(); |
121 | 121 | |
122 | - foreach($items as $item) |
|
122 | + foreach ($items as $item) |
|
123 | 123 | { |
124 | - if($item->getName() === $name) { |
|
124 | + if ($item->getName() === $name) { |
|
125 | 125 | return $item->getID(); |
126 | 126 | } |
127 | 127 | } |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | { |
155 | 155 | $items = $this->getAll(); |
156 | 156 | |
157 | - foreach($items as $item) |
|
157 | + foreach ($items as $item) |
|
158 | 158 | { |
159 | - if($item->getName() === $name) { |
|
159 | + if ($item->getName() === $name) { |
|
160 | 160 | return true; |
161 | 161 | } |
162 | 162 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | { |
177 | 177 | $class = $this->resolveClassName($id, $type); |
178 | 178 | |
179 | - if(!class_exists($class)) |
|
179 | + if (!class_exists($class)) |
|
180 | 180 | { |
181 | 181 | throw new Mailcode_Factory_Exception( |
182 | 182 | 'No such command', |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | $command = new $class($type, $params, $matchedString); |
193 | 193 | |
194 | - if($command instanceof Mailcode_Commands_Command) |
|
194 | + if ($command instanceof Mailcode_Commands_Command) |
|
195 | 195 | { |
196 | 196 | return $command; |
197 | 197 | } |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | |
213 | 213 | $dummy = $this->getDummyCommand($id); |
214 | 214 | |
215 | - if($dummy->supportsType()) |
|
215 | + if ($dummy->supportsType()) |
|
216 | 216 | { |
217 | - if(empty($type)) |
|
217 | + if (empty($type)) |
|
218 | 218 | { |
219 | 219 | $type = $dummy->getDefaultType(); |
220 | 220 | } |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | */ |
253 | 253 | private function getDummyCommand(string $id) : Mailcode_Commands_Command |
254 | 254 | { |
255 | - if(isset(self::$dummyCommands[$id])) { |
|
255 | + if (isset(self::$dummyCommands[$id])) { |
|
256 | 256 | return self::$dummyCommands[$id]; |
257 | 257 | } |
258 | 258 | |
259 | 259 | $class = 'Mailcode\Mailcode_Commands_Command_'.$id; |
260 | 260 | $cmd = new $class('__dummy'); |
261 | 261 | |
262 | - if($cmd instanceof Mailcode_Commands_Command) |
|
262 | + if ($cmd instanceof Mailcode_Commands_Command) |
|
263 | 263 | { |
264 | 264 | self::$dummyCommands[$id] = $cmd; |
265 | 265 | return $cmd; |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | $result = array(); |
285 | 285 | $commands = $this->getAll(); |
286 | 286 | |
287 | - foreach($commands as $command) |
|
287 | + foreach ($commands as $command) |
|
288 | 288 | { |
289 | - if($command instanceof Mailcode_Interfaces_Commands_ProtectedContent) |
|
289 | + if ($command instanceof Mailcode_Interfaces_Commands_ProtectedContent) |
|
290 | 290 | { |
291 | 291 | $result[] = $command; |
292 | 292 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @return $this |
33 | 33 | * @throws ParamsException |
34 | 34 | */ |
35 | - public function setURLDecoding(bool $enabled=true) : self; |
|
35 | + public function setURLDecoding(bool $enabled = true) : self; |
|
36 | 36 | |
37 | 37 | public function isURLDecoded(): bool; |
38 | 38 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * @return $this |
36 | 36 | * @throws Mailcode_Exception |
37 | 37 | */ |
38 | - public function setURLDecoding(bool $enabled=true) : self |
|
38 | + public function setURLDecoding(bool $enabled = true) : self |
|
39 | 39 | { |
40 | 40 | return $this->setEncodingEnabled(Mailcode_Commands_Keywords::TYPE_URLDECODE, $enabled); |
41 | 41 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | * @return $this |
42 | 42 | * @throws Mailcode_Exception |
43 | 43 | */ |
44 | - public function setURLEncoding(bool $enabled=true) : self |
|
44 | + public function setURLEncoding(bool $enabled = true) : self |
|
45 | 45 | { |
46 | 46 | return $this->setEncodingEnabled(Mailcode_Commands_Keywords::TYPE_URLENCODE, $enabled); |
47 | 47 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getTextToken() : Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral |
68 | 68 | { |
69 | - if(isset($this->textToken)) |
|
69 | + if (isset($this->textToken)) |
|
70 | 70 | { |
71 | 71 | return $this->textToken; |
72 | 72 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | public function setText(string $text) : self |
87 | 87 | { |
88 | - if(isset($this->textToken)) |
|
88 | + if (isset($this->textToken)) |
|
89 | 89 | { |
90 | 90 | $this->textToken->setText($text); |
91 | 91 | return $this; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | ->getInfo() |
105 | 105 | ->getStringLiterals(); |
106 | 106 | |
107 | - if(empty($strings)) |
|
107 | + if (empty($strings)) |
|
108 | 108 | { |
109 | 109 | $this->getValidationResult()->makeError( |
110 | 110 | t('No text to encode has been specified.'), |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | ->getInfo() |
123 | 123 | ->getKeywords(); |
124 | 124 | |
125 | - if(!empty($keywords)) |
|
125 | + if (!empty($keywords)) |
|
126 | 126 | { |
127 | 127 | return; |
128 | 128 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | $this->instantiator->checkCommand($cmd); |
45 | 45 | |
46 | - if($cmd instanceof Mailcode_Commands_Command_ShowEncoded) |
|
46 | + if ($cmd instanceof Mailcode_Commands_Command_ShowEncoded) |
|
47 | 47 | { |
48 | 48 | return $cmd; |
49 | 49 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $params = array(); |
62 | 62 | $params[] = $this->instantiator->quoteString($subject); |
63 | 63 | |
64 | - foreach($encodings as $keyword) |
|
64 | + foreach ($encodings as $keyword) |
|
65 | 65 | { |
66 | 66 | $params[] = $this->instantiator->filterKeyword($keyword); |
67 | 67 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $params = $this->collectParams(); |
54 | 54 | $result = array(); |
55 | 55 | |
56 | - foreach($params as $param) |
|
56 | + foreach ($params as $param) |
|
57 | 57 | { |
58 | 58 | $result[$param->getName()] = $param->getValue(); |
59 | 59 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $params = $this->collectParams(); |
70 | 70 | $result = array(); |
71 | 71 | |
72 | - foreach($params as $param) |
|
72 | + foreach ($params as $param) |
|
73 | 73 | { |
74 | 74 | $result[] = $param->getToken(); |
75 | 75 | } |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | |
90 | 90 | $result = array(); |
91 | 91 | |
92 | - foreach($literals as $literal) |
|
92 | + foreach ($literals as $literal) |
|
93 | 93 | { |
94 | 94 | $text = $literal->getText(); |
95 | 95 | |
96 | - if(strpos($text, '=') !== false) |
|
96 | + if (strpos($text, '=') !== false) |
|
97 | 97 | { |
98 | 98 | $param = new QueryParam($literal); |
99 | 99 | $result[$param->getName()] = $param; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | $params = $this->collectParams(); |
109 | 109 | |
110 | - if(isset($params[$name])) |
|
110 | + if (isset($params[$name])) |
|
111 | 111 | { |
112 | 112 | return $params[$name]->getValue(); |
113 | 113 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | { |
127 | 127 | $params = $this->collectParams(); |
128 | 128 | |
129 | - if(isset($params[$name])) |
|
129 | + if (isset($params[$name])) |
|
130 | 130 | { |
131 | 131 | $params[$name]->setValue($value); |
132 | 132 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | { |
150 | 150 | $params = $this->collectParams(); |
151 | 151 | |
152 | - if(isset($params[$name])) |
|
152 | + if (isset($params[$name])) |
|
153 | 153 | { |
154 | 154 | $this->requireParams() |
155 | 155 | ->getInfo() |
@@ -129,8 +129,7 @@ |
||
129 | 129 | if(isset($params[$name])) |
130 | 130 | { |
131 | 131 | $params[$name]->setValue($value); |
132 | - } |
|
133 | - else |
|
132 | + } else |
|
134 | 133 | { |
135 | 134 | $this->addParam($name, $value); |
136 | 135 | } |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | public const VALIDATION_INVALID_DECIMAL_SEPARATOR = 72209; |
31 | 31 | public const VALIDATION_SEPARATORS_SAME_CHARACTER = 72210; |
32 | 32 | |
33 | - /** |
|
34 | - * The default number format string. |
|
35 | - * @var string |
|
36 | - */ |
|
33 | + /** |
|
34 | + * The default number format string. |
|
35 | + * @var string |
|
36 | + */ |
|
37 | 37 | private string $formatString = Mailcode_Number_Info::DEFAULT_FORMAT; |
38 | 38 | |
39 | 39 | /** |
@@ -62,18 +62,18 @@ discard block |
||
62 | 62 | |
63 | 63 | protected function validateSyntax_check_format() : void |
64 | 64 | { |
65 | - $tokens = $this->requireParams() |
|
66 | - ->getInfo() |
|
67 | - ->getStringLiterals(); |
|
65 | + $tokens = $this->requireParams() |
|
66 | + ->getInfo() |
|
67 | + ->getStringLiterals(); |
|
68 | 68 | |
69 | - // no format specified? Use the default one. |
|
70 | - if(empty($tokens)) |
|
71 | - { |
|
72 | - return; |
|
73 | - } |
|
74 | - |
|
75 | - $token = array_pop($tokens); |
|
76 | - $this->parseFormatString($token->getText()); |
|
69 | + // no format specified? Use the default one. |
|
70 | + if(empty($tokens)) |
|
71 | + { |
|
72 | + return; |
|
73 | + } |
|
74 | + |
|
75 | + $token = array_pop($tokens); |
|
76 | + $this->parseFormatString($token->getText()); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | protected function validateSyntax_absolute() : void |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | ); |
109 | 109 | } |
110 | 110 | |
111 | - /** |
|
112 | - * Retrieves the format string used to format the number. |
|
113 | - * |
|
114 | - * @return string |
|
115 | - */ |
|
111 | + /** |
|
112 | + * Retrieves the format string used to format the number. |
|
113 | + * |
|
114 | + * @return string |
|
115 | + */ |
|
116 | 116 | public function getFormatString() : string |
117 | 117 | { |
118 | 118 | return $this->formatString; |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | |
134 | 134 | if($absolute === true && !isset($this->absoluteKeyword)) |
135 | 135 | { |
136 | - $this->requireParams() |
|
137 | - ->getInfo() |
|
138 | - ->addKeyword(Mailcode_Commands_Keywords::TYPE_ABSOLUTE); |
|
136 | + $this->requireParams() |
|
137 | + ->getInfo() |
|
138 | + ->addKeyword(Mailcode_Commands_Keywords::TYPE_ABSOLUTE); |
|
139 | 139 | |
140 | - $this->validateSyntax_absolute(); |
|
140 | + $this->validateSyntax_absolute(); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | return $this; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | ->getStringLiterals(); |
68 | 68 | |
69 | 69 | // no format specified? Use the default one. |
70 | - if(empty($tokens)) |
|
70 | + if (empty($tokens)) |
|
71 | 71 | { |
72 | 72 | return; |
73 | 73 | } |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | ->getInfo() |
83 | 83 | ->getKeywords(); |
84 | 84 | |
85 | - foreach($keywords as $keyword) |
|
85 | + foreach ($keywords as $keyword) |
|
86 | 86 | { |
87 | - if($keyword->getKeyword() === Mailcode_Commands_Keywords::TYPE_ABSOLUTE) |
|
87 | + if ($keyword->getKeyword() === Mailcode_Commands_Keywords::TYPE_ABSOLUTE) |
|
88 | 88 | { |
89 | 89 | $this->absoluteKeyword = $keyword; |
90 | 90 | break; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | { |
97 | 97 | $result = new Mailcode_Number_Info($format); |
98 | 98 | |
99 | - if($result->isValid()) |
|
99 | + if ($result->isValid()) |
|
100 | 100 | { |
101 | 101 | $this->formatString = $format; |
102 | 102 | return; |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | |
126 | 126 | public function setAbsolute(bool $absolute) : Mailcode_Commands_Command_ShowNumber |
127 | 127 | { |
128 | - if($absolute === false && isset($this->absoluteKeyword)) |
|
128 | + if ($absolute === false && isset($this->absoluteKeyword)) |
|
129 | 129 | { |
130 | 130 | $this->requireParams()->getInfo()->removeKeyword($this->absoluteKeyword->getKeyword()); |
131 | 131 | $this->absoluteKeyword = null; |
132 | 132 | } |
133 | 133 | |
134 | - if($absolute === true && !isset($this->absoluteKeyword)) |
|
134 | + if ($absolute === true && !isset($this->absoluteKeyword)) |
|
135 | 135 | { |
136 | 136 | $this->requireParams() |
137 | 137 | ->getInfo() |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | private function addListener(string $eventName, callable $listener) : void |
154 | 154 | { |
155 | - if(!isset($this->listeners[$eventName])) |
|
155 | + if (!isset($this->listeners[$eventName])) |
|
156 | 156 | { |
157 | 157 | $this->listeners[$eventName] = array(); |
158 | 158 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | { |
197 | 197 | $this->triggerEvent(self::EVENT_TOKEN_REMOVED, $token); |
198 | 198 | |
199 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
199 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
200 | 200 | { |
201 | 201 | $this->triggerKeywordRemoved($token->getKeyword()); |
202 | 202 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | { |
223 | 223 | $this->triggerEvent(self::EVENT_TOKEN_ADDED, $token); |
224 | 224 | |
225 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
225 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
226 | 226 | { |
227 | 227 | $this->triggerKeywordAdded($token->getKeyword()); |
228 | 228 | } |
@@ -261,12 +261,12 @@ discard block |
||
261 | 261 | */ |
262 | 262 | private function triggerEvent(string $eventName, ...$listenerArgs) : void |
263 | 263 | { |
264 | - if(!isset($this->listeners[$eventName])) |
|
264 | + if (!isset($this->listeners[$eventName])) |
|
265 | 265 | { |
266 | 266 | return; |
267 | 267 | } |
268 | 268 | |
269 | - foreach($this->listeners[$eventName] as $listener) |
|
269 | + foreach ($this->listeners[$eventName] as $listener) |
|
270 | 270 | { |
271 | 271 | $listener($this->tokenizer, ...$listenerArgs); |
272 | 272 | } |