@@ -56,23 +56,23 @@ |
||
| 56 | 56 | |
| 57 | 57 | private function analyzeURL(string $url) : void |
| 58 | 58 | { |
| 59 | - if(stristr($url, 'tel:') !== false) |
|
| 59 | + if (stristr($url, 'tel:') !== false) |
|
| 60 | 60 | { |
| 61 | 61 | return; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $placeholders = $this->safeguard->getPlaceholdersCollection()->getAll(); |
| 65 | 65 | |
| 66 | - foreach($placeholders as $placeholder) |
|
| 66 | + foreach ($placeholders as $placeholder) |
|
| 67 | 67 | { |
| 68 | 68 | $command = $placeholder->getCommand(); |
| 69 | 69 | |
| 70 | - if(!$command->supportsURLEncoding()) |
|
| 70 | + if (!$command->supportsURLEncoding()) |
|
| 71 | 71 | { |
| 72 | 72 | continue; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if(strstr($url, $placeholder->getReplacementText()) !== false && !$command->isURLDecoded()) |
|
| 75 | + if (strstr($url, $placeholder->getReplacementText()) !== false && !$command->isURLDecoded()) |
|
| 76 | 76 | { |
| 77 | 77 | $command->setURLEncoding(true); |
| 78 | 78 | break; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function getByIndex(int $index) : Mailcode_Parser_Safeguard_Placeholder |
| 41 | 41 | { |
| 42 | - if(isset($this->placeholders[$index])) |
|
| 42 | + if (isset($this->placeholders[$index])) |
|
| 43 | 43 | { |
| 44 | 44 | return $this->placeholders[$index]; |
| 45 | 45 | } |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public function getByCommand(Mailcode_Commands_Command $command) : Mailcode_Parser_Safeguard_Placeholder |
| 55 | 55 | { |
| 56 | - foreach($this->placeholders as $placeholder) |
|
| 56 | + foreach ($this->placeholders as $placeholder) |
|
| 57 | 57 | { |
| 58 | - if($placeholder->getCommand() === $command) |
|
| 58 | + if ($placeholder->getCommand() === $command) |
|
| 59 | 59 | { |
| 60 | 60 | return $placeholder; |
| 61 | 61 | } |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function getByID(int $id) : Mailcode_Parser_Safeguard_Placeholder |
| 79 | 79 | { |
| 80 | - foreach($this->placeholders as $placeholder) |
|
| 80 | + foreach ($this->placeholders as $placeholder) |
|
| 81 | 81 | { |
| 82 | - if($placeholder->getID() === $id) |
|
| 82 | + if ($placeholder->getID() === $id) |
|
| 83 | 83 | { |
| 84 | 84 | return $placeholder; |
| 85 | 85 | } |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function getByString(string $string) : Mailcode_Parser_Safeguard_Placeholder |
| 106 | 106 | { |
| 107 | - foreach($this->placeholders as $placeholder) |
|
| 107 | + foreach ($this->placeholders as $placeholder) |
|
| 108 | 108 | { |
| 109 | - if($placeholder->getReplacementText() === $string) |
|
| 109 | + if ($placeholder->getReplacementText() === $string) |
|
| 110 | 110 | { |
| 111 | 111 | return $placeholder; |
| 112 | 112 | } |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function getStrings() : array |
| 131 | 131 | { |
| 132 | - if(is_array($this->placeholderStrings)) |
|
| 132 | + if (is_array($this->placeholderStrings)) |
|
| 133 | 133 | { |
| 134 | 134 | return $this->placeholderStrings; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $this->placeholderStrings = array(); |
| 138 | 138 | |
| 139 | - foreach($this->placeholders as $placeholder) |
|
| 139 | + foreach ($this->placeholders as $placeholder) |
|
| 140 | 140 | { |
| 141 | 141 | $this->placeholderStrings[] = $placeholder->getReplacementText(); |
| 142 | 142 | } |
@@ -39,14 +39,14 @@ discard block |
||
| 39 | 39 | 'ExtractTokens' |
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var Mailcode_Parser_Statement |
|
| 44 | - */ |
|
| 42 | + /** |
|
| 43 | + * @var Mailcode_Parser_Statement |
|
| 44 | + */ |
|
| 45 | 45 | protected Mailcode_Parser_Statement $statement; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var string |
|
| 49 | - */ |
|
| 47 | + /** |
|
| 48 | + * @var string |
|
| 49 | + */ |
|
| 50 | 50 | protected string $tokenized = ''; |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | protected array $tokensOrdered = array(); |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @var string[] |
|
| 59 | - */ |
|
| 57 | + /** |
|
| 58 | + * @var string[] |
|
| 59 | + */ |
|
| 60 | 60 | protected static array $ids = array(); |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | return $this->statement->getSourceCommand(); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Retrieves all tokens detected in the statement string, in |
|
| 81 | - * the order they were found. |
|
| 82 | - * |
|
| 83 | - * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
| 84 | - */ |
|
| 79 | + /** |
|
| 80 | + * Retrieves all tokens detected in the statement string, in |
|
| 81 | + * the order they were found. |
|
| 82 | + * |
|
| 83 | + * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
| 84 | + */ |
|
| 85 | 85 | public function getTokens() : array |
| 86 | 86 | { |
| 87 | 87 | return $this->tokensOrdered; |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | return !empty($this->tokensOrdered); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Whether there were any unknown tokens in the statement. |
|
| 97 | - * |
|
| 98 | - * @return bool |
|
| 99 | - */ |
|
| 95 | + /** |
|
| 96 | + * Whether there were any unknown tokens in the statement. |
|
| 97 | + * |
|
| 98 | + * @return bool |
|
| 99 | + */ |
|
| 100 | 100 | public function hasUnknown() : bool |
| 101 | 101 | { |
| 102 | 102 | $unknown = $this->getUnknown(); |
@@ -104,11 +104,11 @@ discard block |
||
| 104 | 104 | return !empty($unknown); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * Retrieves all unknown content tokens, if any. |
|
| 109 | - * |
|
| 110 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_Unknown[] |
|
| 111 | - */ |
|
| 107 | + /** |
|
| 108 | + * Retrieves all unknown content tokens, if any. |
|
| 109 | + * |
|
| 110 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_Unknown[] |
|
| 111 | + */ |
|
| 112 | 112 | public function getUnknown() : array |
| 113 | 113 | { |
| 114 | 114 | $result = array(); |
@@ -293,13 +293,13 @@ discard block |
||
| 293 | 293 | return $token; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - /** |
|
| 297 | - * Generates a unique alphabet-based ID without numbers |
|
| 298 | - * to use as token name, to avoid conflicts with the |
|
| 299 | - * numbers detection. |
|
| 300 | - * |
|
| 301 | - * @return string |
|
| 302 | - */ |
|
| 296 | + /** |
|
| 297 | + * Generates a unique alphabet-based ID without numbers |
|
| 298 | + * to use as token name, to avoid conflicts with the |
|
| 299 | + * numbers detection. |
|
| 300 | + * |
|
| 301 | + * @return string |
|
| 302 | + */ |
|
| 303 | 303 | protected function generateID() : string |
| 304 | 304 | { |
| 305 | 305 | static $alphas; |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | $result = array(); |
| 115 | 115 | |
| 116 | - foreach($this->tokensOrdered as $token) |
|
| 116 | + foreach ($this->tokensOrdered as $token) |
|
| 117 | 117 | { |
| 118 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
| 118 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
| 119 | 119 | { |
| 120 | 120 | $result[] = $token; |
| 121 | 121 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | { |
| 129 | 129 | $unknown = $this->getUnknown(); |
| 130 | 130 | |
| 131 | - if(!empty($unknown)) |
|
| 131 | + if (!empty($unknown)) |
|
| 132 | 132 | { |
| 133 | 133 | return array_shift($unknown); |
| 134 | 134 | } |
@@ -140,11 +140,11 @@ discard block |
||
| 140 | 140 | { |
| 141 | 141 | $parts = array(); |
| 142 | 142 | |
| 143 | - foreach($this->tokensOrdered as $token) |
|
| 143 | + foreach ($this->tokensOrdered as $token) |
|
| 144 | 144 | { |
| 145 | 145 | $string = $token->getNormalized(); |
| 146 | 146 | |
| 147 | - if($string !== '') |
|
| 147 | + if ($string !== '') |
|
| 148 | 148 | { |
| 149 | 149 | $parts[] = $string; |
| 150 | 150 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $statement = trim($statement); |
| 169 | 169 | $tokens = array(); |
| 170 | 170 | |
| 171 | - foreach($this->tokenCategories as $tokenCategory) |
|
| 171 | + foreach ($this->tokenCategories as $tokenCategory) |
|
| 172 | 172 | { |
| 173 | 173 | $processor = $this->createProcessor($tokenCategory, $statement, $tokens); |
| 174 | 174 | $processor->process(); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | $instance = new $class($this, $statement, $tokens); |
| 196 | 196 | |
| 197 | - if($instance instanceof Mailcode_Parser_Statement_Tokenizer_Process) |
|
| 197 | + if ($instance instanceof Mailcode_Parser_Statement_Tokenizer_Process) |
|
| 198 | 198 | { |
| 199 | 199 | return $instance; |
| 200 | 200 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | * @param mixed $subject |
| 216 | 216 | * @return Mailcode_Parser_Statement_Tokenizer_Token |
| 217 | 217 | */ |
| 218 | - public function createToken(string $type, string $matchedText, $subject=null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
| 218 | + public function createToken(string $type, string $matchedText, $subject = null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
| 219 | 219 | { |
| 220 | 220 | $tokenID = $this->generateID(); |
| 221 | 221 | |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | $token = new $class($tokenID, $matchedText, $subject, $this->getSourceCommand()); |
| 225 | 225 | |
| 226 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token) |
|
| 226 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token) |
|
| 227 | 227 | { |
| 228 | 228 | return $token; |
| 229 | 229 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | |
| 245 | 245 | $token = $this->appendToken('Keyword', $name); |
| 246 | 246 | |
| 247 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 247 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 248 | 248 | { |
| 249 | 249 | return $token; |
| 250 | 250 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | foreach ($this->tokensOrdered as $checkToken) |
| 265 | 265 | { |
| 266 | - if($checkToken->getID() !== $tokenID) |
|
| 266 | + if ($checkToken->getID() !== $tokenID) |
|
| 267 | 267 | { |
| 268 | 268 | $keep[] = $checkToken; |
| 269 | 269 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @param mixed $subject |
| 283 | 283 | * @return Mailcode_Parser_Statement_Tokenizer_Token |
| 284 | 284 | */ |
| 285 | - protected function appendToken(string $type, string $matchedText, $subject=null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
| 285 | + protected function appendToken(string $type, string $matchedText, $subject = null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
| 286 | 286 | { |
| 287 | 287 | $token = $this->createToken($type, $matchedText, $subject); |
| 288 | 288 | |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | { |
| 305 | 305 | static $alphas; |
| 306 | 306 | |
| 307 | - if(!isset($alphas)) |
|
| 307 | + if (!isset($alphas)) |
|
| 308 | 308 | { |
| 309 | 309 | $alphas = range('A', 'Z'); |
| 310 | 310 | } |
@@ -313,12 +313,12 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | $result = ''; |
| 315 | 315 | |
| 316 | - for($i=0; $i < $amount; $i++) |
|
| 316 | + for ($i = 0; $i < $amount; $i++) |
|
| 317 | 317 | { |
| 318 | 318 | $result .= $alphas[array_rand($alphas)]; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - if(!in_array($result, self::$ids)) |
|
| 321 | + if (!in_array($result, self::$ids)) |
|
| 322 | 322 | { |
| 323 | 323 | self::$ids[] = $result; |
| 324 | 324 | return $result; |
@@ -35,14 +35,14 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | private ?Mailcode_Factory_CommandSets_Set_Misc $misc = null; |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var Mailcode_Factory_CommandSets_Set_Set|NULL |
|
| 40 | - */ |
|
| 38 | + /** |
|
| 39 | + * @var Mailcode_Factory_CommandSets_Set_Set|NULL |
|
| 40 | + */ |
|
| 41 | 41 | private ?Mailcode_Factory_CommandSets_Set_Set $set = null; |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var Mailcode_Factory_CommandSets_Set_ElseIf|NULL |
|
| 45 | - */ |
|
| 43 | + /** |
|
| 44 | + * @var Mailcode_Factory_CommandSets_Set_ElseIf|NULL |
|
| 45 | + */ |
|
| 46 | 46 | private ?Mailcode_Factory_CommandSets_Set_ElseIf $elseIf = null; |
| 47 | 47 | |
| 48 | 48 | public function if() : Mailcode_Factory_CommandSets_Set_If |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | private ?Mailcode_Factory_CommandSets_Set_ElseIf $elseIf = null; |
| 47 | 47 | |
| 48 | - public function if() : Mailcode_Factory_CommandSets_Set_If |
|
| 48 | + public function if () : Mailcode_Factory_CommandSets_Set_If |
|
| 49 | 49 | { |
| 50 | - if(!isset($this->if)) |
|
| 50 | + if (!isset($this->if)) |
|
| 51 | 51 | { |
| 52 | 52 | $this->if = new Mailcode_Factory_CommandSets_Set_If(); |
| 53 | 53 | } |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | return $this->if; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function elseIf() : Mailcode_Factory_CommandSets_Set_ElseIf |
|
| 58 | + public function elseIf () : Mailcode_Factory_CommandSets_Set_ElseIf |
|
| 59 | 59 | { |
| 60 | - if(!isset($this->elseIf)) |
|
| 60 | + if (!isset($this->elseIf)) |
|
| 61 | 61 | { |
| 62 | 62 | $this->elseIf = new Mailcode_Factory_CommandSets_Set_ElseIf(); |
| 63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | public function show() : Mailcode_Factory_CommandSets_Set_Show |
| 69 | 69 | { |
| 70 | - if(!isset($this->show)) |
|
| 70 | + if (!isset($this->show)) |
|
| 71 | 71 | { |
| 72 | 72 | $this->show = new Mailcode_Factory_CommandSets_Set_Show(); |
| 73 | 73 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | public function misc() : Mailcode_Factory_CommandSets_Set_Misc |
| 79 | 79 | { |
| 80 | - if(!isset($this->misc)) |
|
| 80 | + if (!isset($this->misc)) |
|
| 81 | 81 | { |
| 82 | 82 | $this->misc = new Mailcode_Factory_CommandSets_Set_Misc(); |
| 83 | 83 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | public function set() : Mailcode_Factory_CommandSets_Set_Set |
| 89 | 89 | { |
| 90 | - if(!isset($this->set)) |
|
| 90 | + if (!isset($this->set)) |
|
| 91 | 91 | { |
| 92 | 92 | $this->set = new Mailcode_Factory_CommandSets_Set_Set(); |
| 93 | 93 | } |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $keywords = $this->params->getInfo()->getKeywords(); |
| 40 | 40 | |
| 41 | - foreach($keywords as $keyword) |
|
| 41 | + foreach ($keywords as $keyword) |
|
| 42 | 42 | { |
| 43 | - if($keyword->isNoHTML()) |
|
| 43 | + if ($keyword->isNoHTML()) |
|
| 44 | 44 | { |
| 45 | 45 | $this->noHTMLToken = $keyword; |
| 46 | 46 | break; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @return $this |
| 56 | 56 | * @throws Mailcode_Exception |
| 57 | 57 | */ |
| 58 | - public function setHTMLEnabled(bool $enabled=true) : self |
|
| 58 | + public function setHTMLEnabled(bool $enabled = true) : self |
|
| 59 | 59 | { |
| 60 | 60 | $this->params->getInfo()->setKeywordEnabled(Mailcode_Commands_Keywords::TYPE_NOHTML, !$enabled); |
| 61 | 61 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | ->getInfo() |
| 38 | 38 | ->getTokenByIndex(0); |
| 39 | 39 | |
| 40 | - if($contentIDToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) |
|
| 40 | + if ($contentIDToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) |
|
| 41 | 41 | { |
| 42 | 42 | $this->contentIDToken = $contentIDToken; |
| 43 | 43 | $this->loadContent(); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | public function getContentID() : int |
| 54 | 54 | { |
| 55 | - if(isset($this->contentIDToken)) |
|
| 55 | + if (isset($this->contentIDToken)) |
|
| 56 | 56 | { |
| 57 | 57 | return (int)$this->contentIDToken->getValue(); |
| 58 | 58 | } |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | public const ERROR_UNKNOWN_COMMAND_TYPE = 50401; |
| 25 | 25 | public const ERROR_INVALID_COMMAND_INSTANCE = 50402; |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var string |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * @var string |
|
| 29 | + */ |
|
| 30 | 30 | protected string $typeID; |
| 31 | 31 | |
| 32 | 32 | public function __construct(string $typeID) |
@@ -34,22 +34,22 @@ discard block |
||
| 34 | 34 | $this->typeID = $typeID; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Retrieves the syntax' type ID, e.g. "ApacheVelocity". |
|
| 39 | - * @return string |
|
| 40 | - */ |
|
| 37 | + /** |
|
| 38 | + * Retrieves the syntax' type ID, e.g. "ApacheVelocity". |
|
| 39 | + * @return string |
|
| 40 | + */ |
|
| 41 | 41 | public function getTypeID() : string |
| 42 | 42 | { |
| 43 | 43 | return $this->typeID; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Translates a single command to the target syntax. |
|
| 48 | - * |
|
| 49 | - * @param Mailcode_Commands_Command $command |
|
| 50 | - * @throws Mailcode_Translator_Exception |
|
| 51 | - * @return string |
|
| 52 | - */ |
|
| 46 | + /** |
|
| 47 | + * Translates a single command to the target syntax. |
|
| 48 | + * |
|
| 49 | + * @param Mailcode_Commands_Command $command |
|
| 50 | + * @throws Mailcode_Translator_Exception |
|
| 51 | + * @return string |
|
| 52 | + */ |
|
| 53 | 53 | public function translateCommand(Mailcode_Commands_Command $command) : string |
| 54 | 54 | { |
| 55 | 55 | return $this->createTranslator($command)->translate($command); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $command->getID() |
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | - if(!class_exists($class)) |
|
| 66 | + if (!class_exists($class)) |
|
| 67 | 67 | { |
| 68 | 68 | throw new Mailcode_Translator_Exception( |
| 69 | 69 | sprintf('Unknown command %s in translator', $command->getID()), |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | $translator = new $class($command); |
| 79 | 79 | |
| 80 | - if($translator instanceof Mailcode_Translator_Command) |
|
| 80 | + if ($translator instanceof Mailcode_Translator_Command) |
|
| 81 | 81 | { |
| 82 | 82 | return $translator; |
| 83 | 83 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | $subject = $safeguard->makeSafe(); |
| 107 | 107 | |
| 108 | - if(!$safeguard->hasPlaceholders()) |
|
| 108 | + if (!$safeguard->hasPlaceholders()) |
|
| 109 | 109 | { |
| 110 | 110 | return $subject; |
| 111 | 111 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | $replaces = array(); |
| 116 | 116 | |
| 117 | - foreach($placeholders as $placeholder) |
|
| 117 | + foreach ($placeholders as $placeholder) |
|
| 118 | 118 | { |
| 119 | 119 | $command = $placeholder->getCommand(); |
| 120 | 120 | |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | public const URL_ENCODING_DECODE = 'decode'; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * @var Mailcode_Factory_CommandSets|NULL |
|
| 32 | - */ |
|
| 31 | + * @var Mailcode_Factory_CommandSets|NULL |
|
| 32 | + */ |
|
| 33 | 33 | private static ?Mailcode_Factory_CommandSets $commandSets = null; |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -83,33 +83,33 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | - * Creates a renderer instance, which can be used to easily |
|
| 87 | - * create and convert commands to strings. |
|
| 88 | - * |
|
| 89 | - * @return Mailcode_Renderer |
|
| 90 | - */ |
|
| 86 | + * Creates a renderer instance, which can be used to easily |
|
| 87 | + * create and convert commands to strings. |
|
| 88 | + * |
|
| 89 | + * @return Mailcode_Renderer |
|
| 90 | + */ |
|
| 91 | 91 | public static function createRenderer() : Mailcode_Renderer |
| 92 | 92 | { |
| 93 | 93 | return new Mailcode_Renderer(); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Creates a printer instance, which works like the renderer, |
|
| 98 | - * but outputs the generated strings to standard output. |
|
| 99 | - * |
|
| 100 | - * @return Mailcode_Printer |
|
| 101 | - */ |
|
| 96 | + /** |
|
| 97 | + * Creates a printer instance, which works like the renderer, |
|
| 98 | + * but outputs the generated strings to standard output. |
|
| 99 | + * |
|
| 100 | + * @return Mailcode_Printer |
|
| 101 | + */ |
|
| 102 | 102 | public static function createPrinter() : Mailcode_Printer |
| 103 | 103 | { |
| 104 | 104 | return new Mailcode_Printer(); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * Gets/creates the global instance of the date format info |
|
| 109 | - * class, used to handle date formatting aspects. |
|
| 110 | - * |
|
| 111 | - * @return Mailcode_Date_FormatInfo |
|
| 112 | - */ |
|
| 107 | + /** |
|
| 108 | + * Gets/creates the global instance of the date format info |
|
| 109 | + * class, used to handle date formatting aspects. |
|
| 110 | + * |
|
| 111 | + * @return Mailcode_Date_FormatInfo |
|
| 112 | + */ |
|
| 113 | 113 | public static function createDateInfo() : Mailcode_Date_FormatInfo |
| 114 | 114 | { |
| 115 | 115 | return Mailcode_Date_FormatInfo::getInstance(); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return Mailcode_Factory_CommandSets_Set_If |
| 59 | 59 | */ |
| 60 | - public static function if() : Mailcode_Factory_CommandSets_Set_If |
|
| 60 | + public static function if () : Mailcode_Factory_CommandSets_Set_If |
|
| 61 | 61 | { |
| 62 | 62 | return self::getSets()->if(); |
| 63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return Mailcode_Factory_CommandSets_Set_ElseIf |
| 69 | 69 | */ |
| 70 | - public static function elseIf() : Mailcode_Factory_CommandSets_Set_ElseIf |
|
| 70 | + public static function elseIf () : Mailcode_Factory_CommandSets_Set_ElseIf |
|
| 71 | 71 | { |
| 72 | 72 | return self::getSets()->elseIf(); |
| 73 | 73 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | protected static function getSets() : Mailcode_Factory_CommandSets |
| 119 | 119 | { |
| 120 | - if(!isset(self::$commandSets)) |
|
| 120 | + if (!isset(self::$commandSets)) |
|
| 121 | 121 | { |
| 122 | 122 | self::$commandSets = new Mailcode_Factory_CommandSets(); |
| 123 | 123 | } |
@@ -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 $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 $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() |
| 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 | } |