@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $val = $this->validator->createStringLiteral(); |
| 35 | 35 | |
| 36 | - if($val->isValid()) |
|
| 36 | + if ($val->isValid()) |
|
| 37 | 37 | { |
| 38 | 38 | $this->searchTerm = $val->getToken(); |
| 39 | 39 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | public function getSearchTerm() : string |
| 50 | 50 | { |
| 51 | - if($this->searchTerm instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
| 51 | + if ($this->searchTerm instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
| 52 | 52 | { |
| 53 | 53 | return $this->searchTerm->getNormalized(); |
| 54 | 54 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $var = $this->validator->createValue(); |
| 35 | 35 | |
| 36 | - if($var->isValid()) |
|
| 36 | + if ($var->isValid()) |
|
| 37 | 37 | { |
| 38 | 38 | $this->valueToken = $var->getToken(); |
| 39 | 39 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function getValue() : string |
| 55 | 55 | { |
| 56 | - if($this->valueToken instanceof Mailcode_Parser_Statement_Tokenizer_ValueInterface) |
|
| 56 | + if ($this->valueToken instanceof Mailcode_Parser_Statement_Tokenizer_ValueInterface) |
|
| 57 | 57 | { |
| 58 | 58 | return $this->valueToken->getValue(); |
| 59 | 59 | } |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | $var = $this->validator->createOperand(); |
| 41 | 41 | |
| 42 | - if($var->isValid()) |
|
| 42 | + if ($var->isValid()) |
|
| 43 | 43 | { |
| 44 | - if(in_array($var->getSign(), $this->getAllowedOperands())) |
|
| 44 | + if (in_array($var->getSign(), $this->getAllowedOperands())) |
|
| 45 | 45 | { |
| 46 | 46 | $this->operandToken = $var->getToken(); |
| 47 | 47 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | public function getOperand() : Mailcode_Parser_Statement_Tokenizer_Token_Operand |
| 68 | 68 | { |
| 69 | - if($this->operandToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
| 69 | + if ($this->operandToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
| 70 | 70 | { |
| 71 | 71 | return $this->operandToken; |
| 72 | 72 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $id = $token->getID(); |
| 48 | 48 | |
| 49 | - if(!in_array($id, $this->exclude)) |
|
| 49 | + if (!in_array($id, $this->exclude)) |
|
| 50 | 50 | { |
| 51 | 51 | $this->exclude[] = $id; |
| 52 | 52 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | public function limitByClassName(string $className) : Mailcode_Parser_Statement_Info_Pruner |
| 68 | 68 | { |
| 69 | - if(!in_array($className, $this->classNames)) |
|
| 69 | + if (!in_array($className, $this->classNames)) |
|
| 70 | 70 | { |
| 71 | 71 | $this->classNames[] = $className; |
| 72 | 72 | } |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | $tokens = $this->info->getTokens(); |
| 86 | 86 | $keep = array(); |
| 87 | 87 | |
| 88 | - foreach($tokens as $token) |
|
| 88 | + foreach ($tokens as $token) |
|
| 89 | 89 | { |
| 90 | - if(in_array($token->getID(), $this->exclude)) |
|
| 90 | + if (in_array($token->getID(), $this->exclude)) |
|
| 91 | 91 | { |
| 92 | 92 | continue; |
| 93 | 93 | } |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | $result = array(); |
| 137 | 137 | |
| 138 | - foreach($this->tokensOrdered as $token) |
|
| 138 | + foreach ($this->tokensOrdered as $token) |
|
| 139 | 139 | { |
| 140 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
| 140 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
| 141 | 141 | { |
| 142 | 142 | $result[] = $token; |
| 143 | 143 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | { |
| 151 | 151 | $unknown = $this->getUnknown(); |
| 152 | 152 | |
| 153 | - if(!empty($unknown)) |
|
| 153 | + if (!empty($unknown)) |
|
| 154 | 154 | { |
| 155 | 155 | return array_shift($unknown); |
| 156 | 156 | } |
@@ -162,11 +162,11 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | $parts = array(); |
| 164 | 164 | |
| 165 | - foreach($this->tokensOrdered as $token) |
|
| 165 | + foreach ($this->tokensOrdered as $token) |
|
| 166 | 166 | { |
| 167 | 167 | $string = $token->getNormalized(); |
| 168 | 168 | |
| 169 | - if($string != '') |
|
| 169 | + if ($string != '') |
|
| 170 | 170 | { |
| 171 | 171 | $parts[] = $string; |
| 172 | 172 | } |
@@ -179,11 +179,11 @@ discard block |
||
| 179 | 179 | { |
| 180 | 180 | $this->tokenized = trim($statement); |
| 181 | 181 | |
| 182 | - foreach($this->tokenCategories as $token) |
|
| 182 | + foreach ($this->tokenCategories as $token) |
|
| 183 | 183 | { |
| 184 | 184 | $method = 'tokenize_'.$token; |
| 185 | 185 | |
| 186 | - if(!method_exists($this, $method)) |
|
| 186 | + if (!method_exists($this, $method)) |
|
| 187 | 187 | { |
| 188 | 188 | throw new Mailcode_Exception( |
| 189 | 189 | 'Unknown statement token.', |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * @param string $matchedText |
| 208 | 208 | * @param mixed $subject |
| 209 | 209 | */ |
| 210 | - protected function registerToken(string $type, string $matchedText, $subject=null) : void |
|
| 210 | + protected function registerToken(string $type, string $matchedText, $subject = null) : void |
|
| 211 | 211 | { |
| 212 | 212 | $tokenID = $this->generateID(); |
| 213 | 213 | |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | protected function getTokenByID(string $tokenID) : ?Mailcode_Parser_Statement_Tokenizer_Token |
| 226 | 226 | { |
| 227 | - foreach($this->tokensTemporary as $token) |
|
| 227 | + foreach ($this->tokensTemporary as $token) |
|
| 228 | 228 | { |
| 229 | - if($token->getID() === $tokenID) |
|
| 229 | + if ($token->getID() === $tokenID) |
|
| 230 | 230 | { |
| 231 | 231 | return $token; |
| 232 | 232 | } |
@@ -242,9 +242,9 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | protected function tokenize_keywords() : void |
| 244 | 244 | { |
| 245 | - foreach($this->keywords as $keyword) |
|
| 245 | + foreach ($this->keywords as $keyword) |
|
| 246 | 246 | { |
| 247 | - if(strstr($this->tokenized, $keyword)) |
|
| 247 | + if (strstr($this->tokenized, $keyword)) |
|
| 248 | 248 | { |
| 249 | 249 | $this->registerToken('Keyword', $keyword); |
| 250 | 250 | } |
@@ -258,12 +258,12 @@ discard block |
||
| 258 | 258 | // over that could not be tokenized. |
| 259 | 259 | $parts = \AppUtils\ConvertHelper::explodeTrim($this->delimiter, $this->tokenized); |
| 260 | 260 | |
| 261 | - foreach($parts as $part) |
|
| 261 | + foreach ($parts as $part) |
|
| 262 | 262 | { |
| 263 | 263 | $token = $this->getTokenByID($part); |
| 264 | 264 | |
| 265 | 265 | // if the entry is a token, simply add it. |
| 266 | - if($token) |
|
| 266 | + if ($token) |
|
| 267 | 267 | { |
| 268 | 268 | $this->tokensOrdered[] = $token; |
| 269 | 269 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | { |
| 280 | 280 | $vars = Mailcode::create()->findVariables($this->tokenized)->getGroupedByHash(); |
| 281 | 281 | |
| 282 | - foreach($vars as $var) |
|
| 282 | + foreach ($vars as $var) |
|
| 283 | 283 | { |
| 284 | 284 | $this->registerToken('Variable', $var->getMatchedText(), $var); |
| 285 | 285 | } |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | protected function tokenize_operands() : void |
| 289 | 289 | { |
| 290 | - foreach($this->operands as $operand) |
|
| 290 | + foreach ($this->operands as $operand) |
|
| 291 | 291 | { |
| 292 | - if(strstr($this->tokenized, $operand)) |
|
| 292 | + if (strstr($this->tokenized, $operand)) |
|
| 293 | 293 | { |
| 294 | 294 | $this->registerToken('Operand', $operand); |
| 295 | 295 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | $matches = array(); |
| 302 | 302 | preg_match_all('/"(.*)"/sxU', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
| 303 | 303 | |
| 304 | - foreach($matches[0] as $match) |
|
| 304 | + foreach ($matches[0] as $match) |
|
| 305 | 305 | { |
| 306 | 306 | $this->registerToken('StringLiteral', $match); |
| 307 | 307 | } |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | $matches = array(); |
| 313 | 313 | preg_match_all('/-*[0-9]+\s*[.,]\s*[0-9]+|-*[0-9]+/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
| 314 | 314 | |
| 315 | - foreach($matches[0] as $match) |
|
| 315 | + foreach ($matches[0] as $match) |
|
| 316 | 316 | { |
| 317 | 317 | $this->registerToken('Number', $match); |
| 318 | 318 | } |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | { |
| 330 | 330 | static $alphas; |
| 331 | 331 | |
| 332 | - if(!isset($alphas)) |
|
| 332 | + if (!isset($alphas)) |
|
| 333 | 333 | { |
| 334 | 334 | $alphas = range('A', 'Z'); |
| 335 | 335 | } |
@@ -338,12 +338,12 @@ discard block |
||
| 338 | 338 | |
| 339 | 339 | $result = ''; |
| 340 | 340 | |
| 341 | - for($i=0; $i < $amount; $i++) |
|
| 341 | + for ($i = 0; $i < $amount; $i++) |
|
| 342 | 342 | { |
| 343 | 343 | $result .= $alphas[array_rand($alphas)]; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - if(!in_array($result, self::$ids)) |
|
| 346 | + if (!in_array($result, self::$ids)) |
|
| 347 | 347 | { |
| 348 | 348 | self::$ids[] = $result; |
| 349 | 349 | return $result; |
@@ -48,15 +48,15 @@ |
||
| 48 | 48 | ->limitToStringLiterals() |
| 49 | 49 | ->getTokens(); |
| 50 | 50 | |
| 51 | - foreach($tokens as $token) |
|
| 51 | + foreach ($tokens as $token) |
|
| 52 | 52 | { |
| 53 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
| 53 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
| 54 | 54 | { |
| 55 | 55 | $this->searchTerms[] = $token; |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if(empty($this->searchTerms)) |
|
| 59 | + if (empty($this->searchTerms)) |
|
| 60 | 60 | { |
| 61 | 61 | $this->validationResult->makeError( |
| 62 | 62 | t('No search terms found:').' '. |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $this->caseInsensitive = $val->isValid(); |
| 42 | 42 | |
| 43 | - if($val->isValid()) |
|
| 43 | + if ($val->isValid()) |
|
| 44 | 44 | { |
| 45 | 45 | $this->caseToken = $val->getToken(); |
| 46 | 46 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public function getCaseToken() : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword |
| 55 | 55 | { |
| 56 | - if($this->caseToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 56 | + if ($this->caseToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 57 | 57 | { |
| 58 | 58 | return $this->caseToken; |
| 59 | 59 | } |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | |
| 81 | 81 | protected function validateSyntax_comment() : void |
| 82 | 82 | { |
| 83 | - if(empty($this->commentString)) |
|
| 83 | + if (empty($this->commentString)) |
|
| 84 | 84 | { |
| 85 | 85 | $this->validationResult->makeError( |
| 86 | 86 | t('The comment text ist empty.'), |
@@ -20,11 +20,11 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class Mailcode_Factory_Instantiator |
| 22 | 22 | { |
| 23 | - public function buildIf(string $ifType, string $params, string $type='') : Mailcode_Commands_IfBase |
|
| 23 | + public function buildIf(string $ifType, string $params, string $type = '') : Mailcode_Commands_IfBase |
|
| 24 | 24 | { |
| 25 | 25 | $stringType = $type; |
| 26 | 26 | |
| 27 | - if(!empty($type)) |
|
| 27 | + if (!empty($type)) |
|
| 28 | 28 | { |
| 29 | 29 | $stringType = ' '.$type; |
| 30 | 30 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $this->checkCommand($command); |
| 45 | 45 | |
| 46 | - if($command instanceof Mailcode_Commands_IfBase) |
|
| 46 | + if ($command instanceof Mailcode_Commands_IfBase) |
|
| 47 | 47 | { |
| 48 | 48 | return $command; |
| 49 | 49 | } |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | throw $this->exceptionUnexpectedType('IfBase', $command); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public function buildIfVar(string $ifType, string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_IfBase |
|
| 54 | + public function buildIfVar(string $ifType, string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_IfBase |
|
| 55 | 55 | { |
| 56 | - if($quoteValue) |
|
| 56 | + if ($quoteValue) |
|
| 57 | 57 | { |
| 58 | 58 | $value = $this->quoteString($value); |
| 59 | 59 | } |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | * @param bool $caseInsensitive |
| 86 | 86 | * @return Mailcode_Commands_IfBase |
| 87 | 87 | */ |
| 88 | - public function buildIfContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive=false) : Mailcode_Commands_IfBase |
|
| 88 | + public function buildIfContains(string $ifType, string $variable, array $searchTerms, bool $caseInsensitive = false) : Mailcode_Commands_IfBase |
|
| 89 | 89 | { |
| 90 | 90 | $keyword = ' '; |
| 91 | 91 | |
| 92 | - if($caseInsensitive) |
|
| 92 | + if ($caseInsensitive) |
|
| 93 | 93 | { |
| 94 | 94 | $keyword = ' insensitive: '; |
| 95 | 95 | } |
@@ -104,21 +104,21 @@ discard block |
||
| 104 | 104 | return $this->buildIf($ifType, $condition, 'contains'); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public function buildIfBeginsWith(string $ifType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase |
|
| 107 | + public function buildIfBeginsWith(string $ifType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase |
|
| 108 | 108 | { |
| 109 | 109 | return $this->buildIfSearch($ifType, 'begins-with', $variable, $search, $caseInsensitive); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public function buildIfEndsWith(string $ifType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase |
|
| 112 | + public function buildIfEndsWith(string $ifType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase |
|
| 113 | 113 | { |
| 114 | 114 | return $this->buildIfSearch($ifType, 'ends-with', $variable, $search, $caseInsensitive); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - private function buildIfSearch(string $ifType, string $subType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase |
|
| 117 | + private function buildIfSearch(string $ifType, string $subType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase |
|
| 118 | 118 | { |
| 119 | 119 | $keyword = ' '; |
| 120 | 120 | |
| 121 | - if($caseInsensitive) |
|
| 121 | + if ($caseInsensitive) |
|
| 122 | 122 | { |
| 123 | 123 | $keyword = ' insensitive: '; |
| 124 | 124 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | public function checkCommand(Mailcode_Commands_Command $command) : void |
| 149 | 149 | { |
| 150 | - if($command->isValid()) |
|
| 150 | + if ($command->isValid()) |
|
| 151 | 151 | { |
| 152 | 152 | return; |
| 153 | 153 | } |