@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard |
| 136 | 136 | { |
| 137 | - if(empty($delimiter)) |
|
| 137 | + if (empty($delimiter)) |
|
| 138 | 138 | { |
| 139 | 139 | throw new Mailcode_Exception( |
| 140 | 140 | 'Empty delimiter', |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | $safe = str_replace(array_values($replaces), array_keys($replaces), $this->originalString); |
| 187 | 187 | |
| 188 | 188 | // If a formatter has been selected, let it modify the string. |
| 189 | - if(isset($this->formatter)) |
|
| 189 | + if (isset($this->formatter)) |
|
| 190 | 190 | { |
| 191 | 191 | $safe = $this->formatter->format($safe); |
| 192 | 192 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | { |
| 199 | 199 | $class = 'Mailcode\Mailcode_Parser_Safeguard_Formatter_'.$formatterID; |
| 200 | 200 | |
| 201 | - if(class_exists($class)) |
|
| 201 | + if (class_exists($class)) |
|
| 202 | 202 | { |
| 203 | 203 | $this->formatter = new $class($this); |
| 204 | 204 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | { |
| 225 | 225 | $formatter = $this->selectFormatter('SingleLines'); |
| 226 | 226 | |
| 227 | - if($formatter instanceof Mailcode_Parser_Safeguard_Formatter_SingleLines) |
|
| 227 | + if ($formatter instanceof Mailcode_Parser_Safeguard_Formatter_SingleLines) |
|
| 228 | 228 | { |
| 229 | 229 | return $formatter; |
| 230 | 230 | } |
@@ -246,21 +246,21 @@ discard block |
||
| 246 | 246 | * @param bool $highlighted |
| 247 | 247 | * @return string[]string |
| 248 | 248 | */ |
| 249 | - protected function getReplaces(bool $highlighted=false, bool $normalize=false) : array |
|
| 249 | + protected function getReplaces(bool $highlighted = false, bool $normalize = false) : array |
|
| 250 | 250 | { |
| 251 | 251 | $placeholders = $this->getPlaceholders(); |
| 252 | 252 | |
| 253 | 253 | $replaces = array(); |
| 254 | 254 | |
| 255 | - foreach($placeholders as $placeholder) |
|
| 255 | + foreach ($placeholders as $placeholder) |
|
| 256 | 256 | { |
| 257 | 257 | $replace = ''; |
| 258 | 258 | |
| 259 | - if($highlighted) |
|
| 259 | + if ($highlighted) |
|
| 260 | 260 | { |
| 261 | 261 | $replace = $placeholder->getHighlightedText(); |
| 262 | 262 | } |
| 263 | - else if($normalize) |
|
| 263 | + else if ($normalize) |
|
| 264 | 264 | { |
| 265 | 265 | $replace = $placeholder->getNormalizedText(); |
| 266 | 266 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function getPlaceholders() |
| 286 | 286 | { |
| 287 | - if(isset($this->placeholders)) |
|
| 287 | + if (isset($this->placeholders)) |
|
| 288 | 288 | { |
| 289 | 289 | return $this->placeholders; |
| 290 | 290 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | $cmds = $this->getCollection()->getGroupedByHash(); |
| 295 | 295 | |
| 296 | - foreach($cmds as $command) |
|
| 296 | + foreach ($cmds as $command) |
|
| 297 | 297 | { |
| 298 | 298 | self::$counter++; |
| 299 | 299 | |
@@ -307,9 +307,9 @@ discard block |
||
| 307 | 307 | return $this->placeholders; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - protected function restore(string $string, bool $partial=false, bool $highlighted=false) : string |
|
| 310 | + protected function restore(string $string, bool $partial = false, bool $highlighted = false) : string |
|
| 311 | 311 | { |
| 312 | - if(!$partial) |
|
| 312 | + if (!$partial) |
|
| 313 | 313 | { |
| 314 | 314 | $this->requireValidCollection(); |
| 315 | 315 | } |
@@ -318,9 +318,9 @@ discard block |
||
| 318 | 318 | |
| 319 | 319 | $placeholderStrings = array_keys($replaces); |
| 320 | 320 | |
| 321 | - foreach($placeholderStrings as $search) |
|
| 321 | + foreach ($placeholderStrings as $search) |
|
| 322 | 322 | { |
| 323 | - if(!$partial && !strstr($string, $search)) |
|
| 323 | + if (!$partial && !strstr($string, $search)) |
|
| 324 | 324 | { |
| 325 | 325 | throw new Mailcode_Exception( |
| 326 | 326 | 'Command placeholder not found', |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | public function getCollection() : Mailcode_Collection |
| 424 | 424 | { |
| 425 | - if(isset($this->collection)) |
|
| 425 | + if (isset($this->collection)) |
|
| 426 | 426 | { |
| 427 | 427 | return $this->collection; |
| 428 | 428 | } |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | */ |
| 445 | 445 | protected function requireValidCollection() : void |
| 446 | 446 | { |
| 447 | - if($this->getCollection()->isValid()) |
|
| 447 | + if ($this->getCollection()->isValid()) |
|
| 448 | 448 | { |
| 449 | 449 | return; |
| 450 | 450 | } |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | */ |
| 468 | 468 | public function getPlaceholderStrings() : array |
| 469 | 469 | { |
| 470 | - if(is_array($this->placeholderStrings)) |
|
| 470 | + if (is_array($this->placeholderStrings)) |
|
| 471 | 471 | { |
| 472 | 472 | return $this->placeholderStrings; |
| 473 | 473 | } |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | |
| 477 | 477 | $this->placeholderStrings = array(); |
| 478 | 478 | |
| 479 | - foreach($placeholders as $placeholder) |
|
| 479 | + foreach ($placeholders as $placeholder) |
|
| 480 | 480 | { |
| 481 | 481 | $this->placeholderStrings[] = $placeholder->getReplacementText(); |
| 482 | 482 | } |
@@ -502,9 +502,9 @@ discard block |
||
| 502 | 502 | { |
| 503 | 503 | $placeholders = $this->getPlaceholders(); |
| 504 | 504 | |
| 505 | - foreach($placeholders as $placeholder) |
|
| 505 | + foreach ($placeholders as $placeholder) |
|
| 506 | 506 | { |
| 507 | - if($placeholder->getID() === $id) |
|
| 507 | + if ($placeholder->getID() === $id) |
|
| 508 | 508 | { |
| 509 | 509 | return $placeholder; |
| 510 | 510 | } |
@@ -531,9 +531,9 @@ discard block |
||
| 531 | 531 | { |
| 532 | 532 | $placeholders = $this->getPlaceholders(); |
| 533 | 533 | |
| 534 | - foreach($placeholders as $placeholder) |
|
| 534 | + foreach ($placeholders as $placeholder) |
|
| 535 | 535 | { |
| 536 | - if($placeholder->getReplacementText() === $string) |
|
| 536 | + if ($placeholder->getReplacementText() === $string) |
|
| 537 | 537 | { |
| 538 | 538 | return $placeholder; |
| 539 | 539 | } |
@@ -32,37 +32,37 @@ |
||
| 32 | 32 | |
| 33 | 33 | protected function translateBody(Mailcode_Commands_IfBase $command) : string |
| 34 | 34 | { |
| 35 | - if($command instanceof Mailcode_Commands_Command_If_Command) |
|
| 35 | + if ($command instanceof Mailcode_Commands_Command_If_Command) |
|
| 36 | 36 | { |
| 37 | 37 | return $this->translateCommand($command); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 40 | + if ($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 41 | 41 | { |
| 42 | 42 | return $this->translateVariable($command); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if($command instanceof Mailcode_Commands_Command_If_Contains) |
|
| 45 | + if ($command instanceof Mailcode_Commands_Command_If_Contains) |
|
| 46 | 46 | { |
| 47 | 47 | return $this->translateContains($command); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if($command instanceof Mailcode_Commands_Command_If_Empty) |
|
| 50 | + if ($command instanceof Mailcode_Commands_Command_If_Empty) |
|
| 51 | 51 | { |
| 52 | 52 | return $this->translateEmpty($command); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if($command instanceof Mailcode_Commands_Command_If_NotEmpty) |
|
| 55 | + if ($command instanceof Mailcode_Commands_Command_If_NotEmpty) |
|
| 56 | 56 | { |
| 57 | 57 | return $this->translateNotEmpty($command); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if($command instanceof Mailcode_Commands_Command_If_BeginsWith) |
|
| 60 | + if ($command instanceof Mailcode_Commands_Command_If_BeginsWith) |
|
| 61 | 61 | { |
| 62 | 62 | return $this->translateBeginsWith($command); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if($command instanceof Mailcode_Commands_Command_If_EndsWith) |
|
| 65 | + if ($command instanceof Mailcode_Commands_Command_If_EndsWith) |
|
| 66 | 66 | { |
| 67 | 67 | return $this->translateEndsWith($command); |
| 68 | 68 | } |
@@ -32,37 +32,37 @@ |
||
| 32 | 32 | |
| 33 | 33 | protected function translateBody(Mailcode_Commands_IfBase $command) : string |
| 34 | 34 | { |
| 35 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Command) |
|
| 35 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Command) |
|
| 36 | 36 | { |
| 37 | 37 | return $this->translateCommand($command); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 40 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 41 | 41 | { |
| 42 | 42 | return $this->translateVariable($command); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Contains) |
|
| 45 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Contains) |
|
| 46 | 46 | { |
| 47 | 47 | return $this->translateContains($command); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Empty) |
|
| 50 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Empty) |
|
| 51 | 51 | { |
| 52 | 52 | return $this->translateEmpty($command); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if($command instanceof Mailcode_Commands_Command_ElseIf_NotEmpty) |
|
| 55 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_NotEmpty) |
|
| 56 | 56 | { |
| 57 | 57 | return $this->translateNotEmpty($command); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if($command instanceof Mailcode_Commands_Command_ElseIf_BeginsWith) |
|
| 60 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_BeginsWith) |
|
| 61 | 61 | { |
| 62 | 62 | return $this->translateBeginsWith($command); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if($command instanceof Mailcode_Commands_Command_ElseIf_EndsWith) |
|
| 65 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_EndsWith) |
|
| 66 | 66 | { |
| 67 | 67 | return $this->translateEndsWith($command); |
| 68 | 68 | } |
@@ -82,11 +82,11 @@ |
||
| 82 | 82 | return $validate; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function createOperand(string $sign='') : Mailcode_Parser_Statement_Validator_Type_Operand |
|
| 85 | + public function createOperand(string $sign = '') : Mailcode_Parser_Statement_Validator_Type_Operand |
|
| 86 | 86 | { |
| 87 | 87 | $validate = new Mailcode_Parser_Statement_Validator_Type_Operand($this->statement); |
| 88 | 88 | |
| 89 | - if(!empty($sign)) |
|
| 89 | + if (!empty($sign)) |
|
| 90 | 90 | { |
| 91 | 91 | $validate->setOperandSign($sign); |
| 92 | 92 | } |
@@ -72,12 +72,12 @@ discard block |
||
| 72 | 72 | protected function isMatch(Mailcode_Parser_Statement_Tokenizer_Token $token, int $index) : bool |
| 73 | 73 | { |
| 74 | 74 | // filter out tokens of other types |
| 75 | - if(!is_a($token, $this->getTokenClass())) |
|
| 75 | + if (!is_a($token, $this->getTokenClass())) |
|
| 76 | 76 | { |
| 77 | 77 | return false; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if($this->searchIndex >= 0 && $index !== $this->searchIndex) |
|
| 80 | + if ($this->searchIndex >= 0 && $index !== $this->searchIndex) |
|
| 81 | 81 | { |
| 82 | 82 | return false; |
| 83 | 83 | } |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | $tokens = $this->params->getTokens(); |
| 98 | 98 | |
| 99 | - foreach($tokens as $index => $token) |
|
| 99 | + foreach ($tokens as $index => $token) |
|
| 100 | 100 | { |
| 101 | - if($this->isMatch($token, $index)) |
|
| 101 | + if ($this->isMatch($token, $index)) |
|
| 102 | 102 | { |
| 103 | 103 | return $token; |
| 104 | 104 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | { |
| 112 | 112 | $token = $this->findToken(); |
| 113 | 113 | |
| 114 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token && is_a($token, $this->getTokenClass())) |
|
| 114 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token && is_a($token, $this->getTokenClass())) |
|
| 115 | 115 | { |
| 116 | 116 | $this->token = $token; |
| 117 | 117 | return true; |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | */ |
| 59 | 59 | public function validate() : Mailcode_Parser_Statement_Validator_Type |
| 60 | 60 | { |
| 61 | - if(!$this->validated) |
|
| 61 | + if (!$this->validated) |
|
| 62 | 62 | { |
| 63 | 63 | $this->valid = $this->_validate(); |
| 64 | 64 | $this->validated = true; |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | public function getToken() : Mailcode_Parser_Statement_Tokenizer_Token_Keyword |
| 52 | 52 | { |
| 53 | - if($this->token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 53 | + if ($this->token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 54 | 54 | { |
| 55 | 55 | return $this->token; |
| 56 | 56 | } |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | |
| 35 | 35 | public function getToken() : Mailcode_Parser_Statement_Tokenizer_ValueInterface |
| 36 | 36 | { |
| 37 | - if($this->token instanceof Mailcode_Parser_Statement_Tokenizer_ValueInterface) |
|
| 37 | + if ($this->token instanceof Mailcode_Parser_Statement_Tokenizer_ValueInterface) |
|
| 38 | 38 | { |
| 39 | 39 | return $this->token; |
| 40 | 40 | } |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | |
| 35 | 35 | public function getToken() : Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral |
| 36 | 36 | { |
| 37 | - if($this->token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
| 37 | + if ($this->token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
| 38 | 38 | { |
| 39 | 39 | return $this->token; |
| 40 | 40 | } |