@@ -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 |
@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | class Mailcode_Factory_Instantiator |
| 24 | 24 | { |
| 25 | - public function buildIf(string $ifType, string $params, string $type='') : Mailcode_Commands_IfBase |
|
| 25 | + public function buildIf(string $ifType, string $params, string $type = '') : Mailcode_Commands_IfBase |
|
| 26 | 26 | { |
| 27 | 27 | $stringType = $type; |
| 28 | 28 | |
| 29 | - if(!empty($type)) |
|
| 29 | + if (!empty($type)) |
|
| 30 | 30 | { |
| 31 | 31 | $stringType = ' '.$type; |
| 32 | 32 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | $this->checkCommand($command); |
| 47 | 47 | |
| 48 | - if($command instanceof Mailcode_Commands_IfBase) |
|
| 48 | + if ($command instanceof Mailcode_Commands_IfBase) |
|
| 49 | 49 | { |
| 50 | 50 | return $command; |
| 51 | 51 | } |
@@ -53,16 +53,16 @@ discard block |
||
| 53 | 53 | throw $this->exceptionUnexpectedType('IfBase', $command); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public function buildIfVar(string $ifType, string $variable, string $operand, string $value, bool $quoteValue=false, bool $insensitive=false) : Mailcode_Commands_IfBase |
|
| 56 | + public function buildIfVar(string $ifType, string $variable, string $operand, string $value, bool $quoteValue = false, bool $insensitive = false) : Mailcode_Commands_IfBase |
|
| 57 | 57 | { |
| 58 | 58 | $variable = $this->filterVariableName($variable); |
| 59 | 59 | |
| 60 | - if($insensitive) |
|
| 60 | + if ($insensitive) |
|
| 61 | 61 | { |
| 62 | 62 | $value = mb_strtolower($value); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if($quoteValue) |
|
| 65 | + if ($quoteValue) |
|
| 66 | 66 | { |
| 67 | 67 | $value = $this->quoteString($value); |
| 68 | 68 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $value |
| 75 | 75 | ); |
| 76 | 76 | |
| 77 | - if($insensitive) |
|
| 77 | + if ($insensitive) |
|
| 78 | 78 | { |
| 79 | 79 | $condition .= ' '.Mailcode_Commands_Keywords::TYPE_INSENSITIVE; |
| 80 | 80 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @return Mailcode_Commands_IfBase |
| 103 | 103 | * @throws Mailcode_Factory_Exception |
| 104 | 104 | */ |
| 105 | - public function buildIfContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false, string $containsType='contains') : Mailcode_Commands_IfBase |
|
| 105 | + public function buildIfContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false, bool $regexEnabled = false, string $containsType = 'contains') : Mailcode_Commands_IfBase |
|
| 106 | 106 | { |
| 107 | 107 | $condition = sprintf( |
| 108 | 108 | '%s%s"%s"', |
@@ -114,23 +114,23 @@ discard block |
||
| 114 | 114 | return $this->buildIf($ifType, $condition, $containsType); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - private function renderListKeywords(bool $caseInsensitive=false, bool $regexEnabled=false) : string |
|
| 117 | + private function renderListKeywords(bool $caseInsensitive = false, bool $regexEnabled = false) : string |
|
| 118 | 118 | { |
| 119 | 119 | $keywords = array(); |
| 120 | 120 | |
| 121 | - if($caseInsensitive) |
|
| 121 | + if ($caseInsensitive) |
|
| 122 | 122 | { |
| 123 | 123 | $keywords[] = Mailcode_Commands_Keywords::TYPE_INSENSITIVE; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if($regexEnabled) |
|
| 126 | + if ($regexEnabled) |
|
| 127 | 127 | { |
| 128 | 128 | $keywords[] = Mailcode_Commands_Keywords::TYPE_REGEX; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | $keywordsString = ''; |
| 132 | 132 | |
| 133 | - if(!empty($keywords)) |
|
| 133 | + if (!empty($keywords)) |
|
| 134 | 134 | { |
| 135 | 135 | $keywordsString = ' '.implode(' ', $keywords); |
| 136 | 136 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @return Mailcode_Commands_IfBase |
| 148 | 148 | * @throws Mailcode_Factory_Exception |
| 149 | 149 | */ |
| 150 | - public function buildIfNotContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false) : Mailcode_Commands_IfBase |
|
| 150 | + public function buildIfNotContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false, bool $regexEnabled = false) : Mailcode_Commands_IfBase |
|
| 151 | 151 | { |
| 152 | 152 | return $this->buildIfContains($ifType, $variable, $searchTerms, $caseInsensitive, $regexEnabled, 'not-contains'); |
| 153 | 153 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @return Mailcode_Commands_IfBase |
| 163 | 163 | * @throws Mailcode_Factory_Exception |
| 164 | 164 | */ |
| 165 | - public function buildIfListContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false, string $containsType='list-contains') : Mailcode_Commands_IfBase |
|
| 165 | + public function buildIfListContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false, bool $regexEnabled = false, string $containsType = 'list-contains') : Mailcode_Commands_IfBase |
|
| 166 | 166 | { |
| 167 | 167 | return $this->buildIfContains($ifType, $variable, $searchTerms, $caseInsensitive, $regexEnabled, $containsType); |
| 168 | 168 | } |
@@ -176,17 +176,17 @@ discard block |
||
| 176 | 176 | * @return Mailcode_Commands_IfBase |
| 177 | 177 | * @throws Mailcode_Factory_Exception |
| 178 | 178 | */ |
| 179 | - public function buildIfListNotContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false, bool $regexEnabled=false) : Mailcode_Commands_IfBase |
|
| 179 | + public function buildIfListNotContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false, bool $regexEnabled = false) : Mailcode_Commands_IfBase |
|
| 180 | 180 | { |
| 181 | 181 | return $this->buildIfContains($ifType, $variable, $searchTerms, $caseInsensitive, $regexEnabled, 'list-not-contains'); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - public function buildIfBeginsWith(string $ifType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase |
|
| 184 | + public function buildIfBeginsWith(string $ifType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase |
|
| 185 | 185 | { |
| 186 | 186 | return $this->buildIfSearch($ifType, 'begins-with', $variable, $search, $caseInsensitive); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - public function buildIfEndsWith(string $ifType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase |
|
| 189 | + public function buildIfEndsWith(string $ifType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase |
|
| 190 | 190 | { |
| 191 | 191 | return $this->buildIfSearch($ifType, 'ends-with', $variable, $search, $caseInsensitive); |
| 192 | 192 | } |
@@ -236,11 +236,11 @@ discard block |
||
| 236 | 236 | ); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - private function buildIfSearch(string $ifType, string $subType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase |
|
| 239 | + private function buildIfSearch(string $ifType, string $subType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase |
|
| 240 | 240 | { |
| 241 | 241 | $keyword = ' '; |
| 242 | 242 | |
| 243 | - if($caseInsensitive) |
|
| 243 | + if ($caseInsensitive) |
|
| 244 | 244 | { |
| 245 | 245 | $keyword = ' '.Mailcode_Commands_Keywords::TYPE_INSENSITIVE; |
| 246 | 246 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | public function checkCommand(Mailcode_Commands_Command $command) : void |
| 276 | 276 | { |
| 277 | - if($command->isValid()) |
|
| 277 | + if ($command->isValid()) |
|
| 278 | 278 | { |
| 279 | 279 | return; |
| 280 | 280 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | */ |
| 304 | 304 | public function setEncoding(Mailcode_Commands_Command $cmd, string $urlEncoding) : void |
| 305 | 305 | { |
| 306 | - if($cmd instanceof Mailcode_Interfaces_Commands_Validation_URLEncode) |
|
| 306 | + if ($cmd instanceof Mailcode_Interfaces_Commands_Validation_URLEncode) |
|
| 307 | 307 | { |
| 308 | 308 | $cmd->setURLEncoding(false); |
| 309 | 309 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if($cmd instanceof Mailcode_Interfaces_Commands_Validation_URLDecode) |
|
| 316 | + if ($cmd instanceof Mailcode_Interfaces_Commands_Validation_URLDecode) |
|
| 317 | 317 | { |
| 318 | 318 | $cmd->setURLDecoding(false); |
| 319 | 319 | |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | public function quoteString(string $string) : string |
| 334 | 334 | { |
| 335 | - if(substr($string, 0, 1) === '"' && substr($string, -1, 1) === '"') { |
|
| 335 | + if (substr($string, 0, 1) === '"' && substr($string, -1, 1) === '"') { |
|
| 336 | 336 | return $string; |
| 337 | 337 | } |
| 338 | 338 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | |
| 37 | 37 | $this->instantiator->checkCommand($cmd); |
| 38 | 38 | |
| 39 | - if($cmd instanceof Mailcode_Commands_Command_ShowSnippet) |
|
| 39 | + if ($cmd instanceof Mailcode_Commands_Command_ShowSnippet) |
|
| 40 | 40 | { |
| 41 | 41 | return $cmd; |
| 42 | 42 | } |
@@ -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 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @return Mailcode_Commands_Command_ShowPhone |
| 36 | 36 | * @throws Mailcode_Factory_Exception |
| 37 | 37 | */ |
| 38 | - public function create(string $variableName, string $sourceFormat, string $urlEncoding=Mailcode_Factory::URL_ENCODING_NONE) : Mailcode_Commands_Command_ShowPhone |
|
| 38 | + public function create(string $variableName, string $sourceFormat, string $urlEncoding = Mailcode_Factory::URL_ENCODING_NONE) : Mailcode_Commands_Command_ShowPhone |
|
| 39 | 39 | { |
| 40 | 40 | $variableName = $this->instantiator->filterVariableName($variableName); |
| 41 | 41 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $this->instantiator->checkCommand($cmd); |
| 59 | 59 | $this->instantiator->setEncoding($cmd, $urlEncoding); |
| 60 | 60 | |
| 61 | - if($cmd instanceof Mailcode_Commands_Command_ShowPhone) |
|
| 61 | + if ($cmd instanceof Mailcode_Commands_Command_ShowPhone) |
|
| 62 | 62 | { |
| 63 | 63 | return $cmd; |
| 64 | 64 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | class Number extends Mailcode_Factory_CommandSets_Set |
| 25 | 25 | { |
| 26 | - public function create(string $variableName, string $formatString="", bool $absolute=false) : Mailcode_Commands_Command_ShowNumber |
|
| 26 | + public function create(string $variableName, string $formatString = "", bool $absolute = false) : Mailcode_Commands_Command_ShowNumber |
|
| 27 | 27 | { |
| 28 | 28 | $variableName = $this->instantiator->filterVariableName($variableName); |
| 29 | 29 | $paramsString = $this->compileNumberParams($formatString, $absolute); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | $this->instantiator->checkCommand($cmd); |
| 43 | 43 | |
| 44 | - if($cmd instanceof Mailcode_Commands_Command_ShowNumber) |
|
| 44 | + if ($cmd instanceof Mailcode_Commands_Command_ShowNumber) |
|
| 45 | 45 | { |
| 46 | 46 | return $cmd; |
| 47 | 47 | } |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | throw $this->instantiator->exceptionUnexpectedType('ShowNumber', $cmd); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - private function compileNumberParams(string $formatString="", bool $absolute=false) : string |
|
| 52 | + private function compileNumberParams(string $formatString = "", bool $absolute = false) : string |
|
| 53 | 53 | { |
| 54 | 54 | $params = array(); |
| 55 | 55 | |
| 56 | - if(!empty($formatString)) |
|
| 56 | + if (!empty($formatString)) |
|
| 57 | 57 | { |
| 58 | 58 | $params[] = sprintf( |
| 59 | 59 | ' "%s"', |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | ); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if($absolute) |
|
| 64 | + if ($absolute) |
|
| 65 | 65 | { |
| 66 | 66 | $params[] = ' absolute:'; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if(!empty($params)) |
|
| 69 | + if (!empty($params)) |
|
| 70 | 70 | { |
| 71 | 71 | return ' '.implode(' ', $params); |
| 72 | 72 | } |
@@ -62,23 +62,23 @@ |
||
| 62 | 62 | |
| 63 | 63 | public function getNestedMailcode() : Mailcode_Collection |
| 64 | 64 | { |
| 65 | - if(isset($this->nestedMailcode)) |
|
| 66 | - { |
|
| 67 | - return $this->nestedMailcode; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - if($this->isMailcodeEnabled()) |
|
| 71 | - { |
|
| 72 | - $collection = Mailcode::create()->parseString($this->getContent()); |
|
| 73 | - } |
|
| 74 | - else |
|
| 75 | - { |
|
| 76 | - $collection = new Mailcode_Collection(); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - $this->nestedMailcode = $collection; |
|
| 80 | - |
|
| 81 | - return $collection; |
|
| 65 | + if(isset($this->nestedMailcode)) |
|
| 66 | + { |
|
| 67 | + return $this->nestedMailcode; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + if($this->isMailcodeEnabled()) |
|
| 71 | + { |
|
| 72 | + $collection = Mailcode::create()->parseString($this->getContent()); |
|
| 73 | + } |
|
| 74 | + else |
|
| 75 | + { |
|
| 76 | + $collection = new Mailcode_Collection(); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + $this->nestedMailcode = $collection; |
|
| 80 | + |
|
| 81 | + return $collection; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | protected function validateSyntax_nested_mailcode() : void |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | ->getInfo() |
| 48 | 48 | ->getTokenByIndex(0); |
| 49 | 49 | |
| 50 | - if($contentIDToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) |
|
| 50 | + if ($contentIDToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) |
|
| 51 | 51 | { |
| 52 | 52 | $this->contentIDToken = $contentIDToken; |
| 53 | 53 | $this->loadContent(); |
@@ -62,12 +62,12 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | public function getNestedMailcode() : Mailcode_Collection |
| 64 | 64 | { |
| 65 | - if(isset($this->nestedMailcode)) |
|
| 65 | + if (isset($this->nestedMailcode)) |
|
| 66 | 66 | { |
| 67 | 67 | return $this->nestedMailcode; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if($this->isMailcodeEnabled()) |
|
| 70 | + if ($this->isMailcodeEnabled()) |
|
| 71 | 71 | { |
| 72 | 72 | $collection = Mailcode::create()->parseString($this->getContent()); |
| 73 | 73 | } |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $collection = $this->getNestedMailcode(); |
| 87 | 87 | |
| 88 | - if($collection->isValid()) |
|
| 88 | + if ($collection->isValid()) |
|
| 89 | 89 | { |
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $errors = $collection->getErrors(); |
| 94 | 94 | |
| 95 | - foreach($errors as $error) |
|
| 95 | + foreach ($errors as $error) |
|
| 96 | 96 | { |
| 97 | 97 | $this->getValidationResult()->makeError( |
| 98 | 98 | $error->getMessage(), |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | public function getContentID() : int |
| 105 | 105 | { |
| 106 | - if(isset($this->contentIDToken)) |
|
| 106 | + if (isset($this->contentIDToken)) |
|
| 107 | 107 | { |
| 108 | 108 | return (int)$this->contentIDToken->getValue(); |
| 109 | 109 | } |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | { |
| 134 | 134 | $variables = parent::getVariables(); |
| 135 | 135 | |
| 136 | - if($this->isMailcodeEnabled()) |
|
| 136 | + if ($this->isMailcodeEnabled()) |
|
| 137 | 137 | { |
| 138 | 138 | $nested = $this->getNestedMailcode() |
| 139 | 139 | ->getVariables() |
| 140 | 140 | ->getAll(); |
| 141 | 141 | |
| 142 | - foreach($nested as $variable) |
|
| 142 | + foreach ($nested as $variable) |
|
| 143 | 143 | { |
| 144 | 144 | $variables->add($variable); |
| 145 | 145 | } |
@@ -70,8 +70,7 @@ |
||
| 70 | 70 | if($this->isMailcodeEnabled()) |
| 71 | 71 | { |
| 72 | 72 | $collection = Mailcode::create()->parseString($this->getContent()); |
| 73 | - } |
|
| 74 | - else |
|
| 73 | + } else |
|
| 75 | 74 | { |
| 76 | 75 | $collection = new Mailcode_Collection(); |
| 77 | 76 | } |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | use Mailcode_Traits_Commands_Validation_Variable; |
| 26 | 26 | use Mailcode_Traits_Commands_Validation_CaseSensitive; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral[] |
|
| 30 | - */ |
|
| 28 | + /** |
|
| 29 | + * @var Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral[] |
|
| 30 | + */ |
|
| 31 | 31 | protected array $searchTerms = array(); |
| 32 | 32 | |
| 33 | 33 | protected function getValidations() : array |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Retrieves all search terms. |
|
| 65 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral[] |
|
| 66 | - */ |
|
| 63 | + /** |
|
| 64 | + * Retrieves all search terms. |
|
| 65 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral[] |
|
| 66 | + */ |
|
| 67 | 67 | public function getSearchTerms() : array |
| 68 | 68 | { |
| 69 | 69 | return $this->searchTerms; |
@@ -45,12 +45,12 @@ |
||
| 45 | 45 | ->getInfo() |
| 46 | 46 | ->getStringLiterals(); |
| 47 | 47 | |
| 48 | - foreach($tokens as $token) |
|
| 48 | + foreach ($tokens as $token) |
|
| 49 | 49 | { |
| 50 | 50 | $this->searchTerms[] = $token; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if(empty($this->searchTerms)) |
|
| 53 | + if (empty($this->searchTerms)) |
|
| 54 | 54 | { |
| 55 | 55 | $this->validationResult->makeError( |
| 56 | 56 | t('No search terms found:').' '. |
@@ -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 | } |