@@ -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 | } |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | protected string $matchedText; |
| 25 | 25 | private ?Mailcode_Commands_Command $sourceCommand; |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var mixed |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * @var mixed |
|
| 29 | + */ |
|
| 30 | 30 | protected $subject; |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -58,20 +58,20 @@ discard block |
||
| 58 | 58 | return $this->sourceCommand; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * The ID of the type. i.e. the class name ("Keyword", "StringLiteral"). |
|
| 63 | - * @return string |
|
| 64 | - */ |
|
| 61 | + /** |
|
| 62 | + * The ID of the type. i.e. the class name ("Keyword", "StringLiteral"). |
|
| 63 | + * @return string |
|
| 64 | + */ |
|
| 65 | 65 | public function getTypeID() : string |
| 66 | 66 | { |
| 67 | 67 | $parts = explode('_', get_class($this)); |
| 68 | 68 | return array_pop($parts); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Retrieves a unique ID of the token. |
|
| 73 | - * @return string |
|
| 74 | - */ |
|
| 71 | + /** |
|
| 72 | + * Retrieves a unique ID of the token. |
|
| 73 | + * @return string |
|
| 74 | + */ |
|
| 75 | 75 | public function getID() : string |
| 76 | 76 | { |
| 77 | 77 | return $this->tokenID; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param mixed $subject |
| 37 | 37 | * @param Mailcode_Commands_Command|null $sourceCommand |
| 38 | 38 | */ |
| 39 | - public function __construct(string $tokenID, string $matchedText, $subject=null, ?Mailcode_Commands_Command $sourceCommand=null) |
|
| 39 | + public function __construct(string $tokenID, string $matchedText, $subject = null, ?Mailcode_Commands_Command $sourceCommand = null) |
|
| 40 | 40 | { |
| 41 | 41 | $this->tokenID = $tokenID; |
| 42 | 42 | $this->matchedText = $matchedText; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getName() : string |
| 65 | 65 | { |
| 66 | - if(isset($this->nameToken)) { |
|
| 66 | + if (isset($this->nameToken)) { |
|
| 67 | 67 | return $this->nameToken->getParamName(); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | { |
| 102 | 102 | $replaces = array(); |
| 103 | 103 | |
| 104 | - foreach(self::$charsEncoded as $char => $placeholder) |
|
| 104 | + foreach (self::$charsEncoded as $char => $placeholder) |
|
| 105 | 105 | { |
| 106 | 106 | $escaped = self::$charsEscaped[$char]; |
| 107 | 107 | |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | public function getVariable() : Mailcode_Variables_Variable |
| 30 | 30 | { |
| 31 | - if($this->subject instanceof Mailcode_Variables_Variable) |
|
| 31 | + if ($this->subject instanceof Mailcode_Variables_Variable) |
|
| 32 | 32 | { |
| 33 | 33 | return $this->subject; |
| 34 | 34 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | $token = $this->info->getTokenByIndex($index); |
| 45 | 45 | |
| 46 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 46 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 47 | 47 | { |
| 48 | 48 | return $token; |
| 49 | 49 | } |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | $tokens = $this->getAll(); |
| 64 | 64 | |
| 65 | - foreach($tokens as $token) |
|
| 65 | + foreach ($tokens as $token) |
|
| 66 | 66 | { |
| 67 | - if($token->getKeyword() === $name) |
|
| 67 | + if ($token->getKeyword() === $name) |
|
| 68 | 68 | { |
| 69 | 69 | return $token; |
| 70 | 70 | } |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | $result = array(); |
| 82 | 82 | $tokens = $this->info->getTokens(); |
| 83 | 83 | |
| 84 | - foreach($tokens as $token) |
|
| 84 | + foreach ($tokens as $token) |
|
| 85 | 85 | { |
| 86 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 86 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 87 | 87 | { |
| 88 | 88 | $result[] = $token; |
| 89 | 89 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function setEnabled(string $keyword, bool $enabled) : Mailcode_Parser_Statement_Info_Keywords |
| 104 | 104 | { |
| 105 | - if($enabled) |
|
| 105 | + if ($enabled) |
|
| 106 | 106 | { |
| 107 | 107 | return $this->add($keyword); |
| 108 | 108 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | $keyword = rtrim($keyword, ':').':'; |
| 123 | 123 | |
| 124 | - if(!$this->hasKeyword($keyword)) |
|
| 124 | + if (!$this->hasKeyword($keyword)) |
|
| 125 | 125 | { |
| 126 | 126 | $this->tokenizer->appendKeyword($keyword); |
| 127 | 127 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | foreach ($keywords as $kw) |
| 168 | 168 | { |
| 169 | - if($kw->getKeyword() === $keyword) |
|
| 169 | + if ($kw->getKeyword() === $keyword) |
|
| 170 | 170 | { |
| 171 | 171 | return true; |
| 172 | 172 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | private function stripStyleTags() : void |
| 81 | 81 | { |
| 82 | - if(!ConvertHelper::isStringHTML($this->subject)) |
|
| 82 | + if (!ConvertHelper::isStringHTML($this->subject)) |
|
| 83 | 83 | { |
| 84 | 84 | return; |
| 85 | 85 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | private function escapeRegexBracketMatch(string $subject, string $needle) : string |
| 95 | 95 | { |
| 96 | - $replacement = str_replace( |
|
| 96 | + $replacement = str_replace( |
|
| 97 | 97 | array('{', '}'), |
| 98 | 98 | array('\{', '\}'), |
| 99 | 99 | $needle |
@@ -33,21 +33,21 @@ discard block |
||
| 33 | 33 | * @return Mailcode_Commands_Command_ShowURL |
| 34 | 34 | * @throws Mailcode_Factory_Exception |
| 35 | 35 | */ |
| 36 | - public function create(string $url, ?string $trackingID=null, array $queryParams=array()) : Mailcode_Commands_Command_ShowURL |
|
| 36 | + public function create(string $url, ?string $trackingID = null, array $queryParams = array()) : Mailcode_Commands_Command_ShowURL |
|
| 37 | 37 | { |
| 38 | 38 | $contentID = PreParser::storeContent($url); |
| 39 | 39 | |
| 40 | 40 | $params = array(); |
| 41 | 41 | $params[] = (string)$contentID; |
| 42 | 42 | |
| 43 | - if($trackingID !== null) |
|
| 43 | + if ($trackingID !== null) |
|
| 44 | 44 | { |
| 45 | 45 | $params[] = sprintf('"%s"', $trackingID); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if(!empty($queryParams)) |
|
| 48 | + if (!empty($queryParams)) |
|
| 49 | 49 | { |
| 50 | - foreach($queryParams as $name => $value) |
|
| 50 | + foreach ($queryParams as $name => $value) |
|
| 51 | 51 | { |
| 52 | 52 | $params[] = sprintf( |
| 53 | 53 | '"%s=%s"', |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | $this->instantiator->checkCommand($cmd); |
| 70 | 70 | |
| 71 | - if($cmd instanceof Mailcode_Commands_Command_ShowURL) |
|
| 71 | + if ($cmd instanceof Mailcode_Commands_Command_ShowURL) |
|
| 72 | 72 | { |
| 73 | 73 | return $cmd; |
| 74 | 74 | } |