@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | ->getInfo() |
| 62 | 62 | ->getStringLiterals(); |
| 63 | 63 | |
| 64 | - if(empty($literals)) |
|
| 64 | + if (empty($literals)) |
|
| 65 | 65 | { |
| 66 | 66 | return; |
| 67 | 67 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $id = $trackingID->getText(); |
| 72 | 72 | |
| 73 | - if(strpos($id, '=') === false) |
|
| 73 | + if (strpos($id, '=') === false) |
|
| 74 | 74 | { |
| 75 | 75 | $this->trackingID = $id; |
| 76 | 76 | $this->trackingIDToken = $trackingID; |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | $this->noTrackingToken = null; |
| 56 | 56 | $this->trackingEnabled = true; |
| 57 | 57 | |
| 58 | - foreach($keywords as $keyword) |
|
| 58 | + foreach ($keywords as $keyword) |
|
| 59 | 59 | { |
| 60 | - if($keyword->getKeyword() === Mailcode_Commands_Keywords::TYPE_NO_TRACKING) |
|
| 60 | + if ($keyword->getKeyword() === Mailcode_Commands_Keywords::TYPE_NO_TRACKING) |
|
| 61 | 61 | { |
| 62 | 62 | $this->noTrackingToken = $keyword; |
| 63 | 63 | $this->trackingEnabled = false; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | public function getNoTrackingToken() : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword |
| 91 | 91 | { |
| 92 | - if($this->noTrackingToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 92 | + if ($this->noTrackingToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 93 | 93 | { |
| 94 | 94 | return $this->noTrackingToken; |
| 95 | 95 | } |
@@ -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(); |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | return in_array($id, $ids); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - /** |
|
| 147 | - * Checks wether the specified name exists. |
|
| 148 | - * |
|
| 149 | - * @param string $name For example: "showvar". |
|
| 150 | - * @return bool |
|
| 151 | - */ |
|
| 146 | + /** |
|
| 147 | + * Checks wether the specified name exists. |
|
| 148 | + * |
|
| 149 | + * @param string $name For example: "showvar". |
|
| 150 | + * @return bool |
|
| 151 | + */ |
|
| 152 | 152 | public function nameExists(string $name) : bool |
| 153 | 153 | { |
| 154 | 154 | $items = $this->getAll(); |
@@ -216,14 +216,14 @@ discard block |
||
| 216 | 216 | return $class; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - /** |
|
| 220 | - * Translates the command type to the expected class naming scheme. |
|
| 221 | - * |
|
| 222 | - * Example: not-empty => NotEmpty |
|
| 223 | - * |
|
| 224 | - * @param string $type |
|
| 225 | - * @return string |
|
| 226 | - */ |
|
| 219 | + /** |
|
| 220 | + * Translates the command type to the expected class naming scheme. |
|
| 221 | + * |
|
| 222 | + * Example: not-empty => NotEmpty |
|
| 223 | + * |
|
| 224 | + * @param string $type |
|
| 225 | + * @return string |
|
| 226 | + */ |
|
| 227 | 227 | private function adjustTypeName(string $type) : string |
| 228 | 228 | { |
| 229 | 229 | $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 | } |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | { |
| 154 | 154 | $items = $this->getAll(); |
| 155 | 155 | |
| 156 | - foreach($items as $item) |
|
| 156 | + foreach ($items as $item) |
|
| 157 | 157 | { |
| 158 | - if($item->getName() === $name) { |
|
| 158 | + if ($item->getName() === $name) { |
|
| 159 | 159 | return true; |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | { |
| 168 | 168 | $class = $this->resolveClassName($id, $type); |
| 169 | 169 | |
| 170 | - if(!class_exists($class)) |
|
| 170 | + if (!class_exists($class)) |
|
| 171 | 171 | { |
| 172 | 172 | throw new Mailcode_Exception( |
| 173 | 173 | 'No such command', |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | $command = new $class($type, $params, $matchedString); |
| 184 | 184 | |
| 185 | - if($command instanceof Mailcode_Commands_Command) |
|
| 185 | + if ($command instanceof Mailcode_Commands_Command) |
|
| 186 | 186 | { |
| 187 | 187 | return $command; |
| 188 | 188 | } |
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | $dummy = $this->getDummyCommand($id); |
| 205 | 205 | |
| 206 | - if($dummy->supportsType()) |
|
| 206 | + if ($dummy->supportsType()) |
|
| 207 | 207 | { |
| 208 | - if(empty($type)) |
|
| 208 | + if (empty($type)) |
|
| 209 | 209 | { |
| 210 | 210 | $type = $dummy->getDefaultType(); |
| 211 | 211 | } |
@@ -243,14 +243,14 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | private function getDummyCommand(string $id) : Mailcode_Commands_Command |
| 245 | 245 | { |
| 246 | - if(isset(self::$dummyCommands[$id])) { |
|
| 246 | + if (isset(self::$dummyCommands[$id])) { |
|
| 247 | 247 | return self::$dummyCommands[$id]; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | $class = 'Mailcode\Mailcode_Commands_Command_'.$id; |
| 251 | 251 | $cmd = new $class('__dummy'); |
| 252 | 252 | |
| 253 | - if($cmd instanceof Mailcode_Commands_Command) |
|
| 253 | + if ($cmd instanceof Mailcode_Commands_Command) |
|
| 254 | 254 | { |
| 255 | 255 | self::$dummyCommands[$id] = $cmd; |
| 256 | 256 | return $cmd; |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | $result = array(); |
| 276 | 276 | $commands = $this->getAll(); |
| 277 | 277 | |
| 278 | - foreach($commands as $command) |
|
| 278 | + foreach ($commands as $command) |
|
| 279 | 279 | { |
| 280 | - if($command instanceof Mailcode_Interfaces_Commands_ProtectedContent) |
|
| 280 | + if ($command instanceof Mailcode_Interfaces_Commands_ProtectedContent) |
|
| 281 | 281 | { |
| 282 | 282 | $result[] = $command; |
| 283 | 283 | } |
@@ -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 | } |
@@ -22,9 +22,9 @@ |
||
| 22 | 22 | { |
| 23 | 23 | public const REGEX_VARIABLE_NAME = '/\$\s*([A-Z0-9_]+)\s*\.\s*([A-Z0-9_]+)|\$\s*([A-Z0-9_]+)/six'; |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var Mailcode_Variables_Collection_Regular |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var Mailcode_Variables_Collection_Regular |
|
| 27 | + */ |
|
| 28 | 28 | protected Mailcode_Variables_Collection_Regular $collection; |
| 29 | 29 | |
| 30 | 30 | /** |