@@ -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 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * @return $this |
36 | 36 | * @throws Mailcode_Exception |
37 | 37 | */ |
38 | - public function setURLDecoding(bool $decode=true) : self |
|
38 | + public function setURLDecoding(bool $decode = true) : self |
|
39 | 39 | { |
40 | 40 | return $this->setEncodingEnabled(Mailcode_Commands_Keywords::TYPE_URLDECODE, $decode); |
41 | 41 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | * @return $this |
42 | 42 | * @throws Mailcode_Exception |
43 | 43 | */ |
44 | - public function setURLEncoding(bool $encoding=true) : self |
|
44 | + public function setURLEncoding(bool $encoding = true) : self |
|
45 | 45 | { |
46 | 46 | return $this->setEncodingEnabled(Mailcode_Commands_Keywords::TYPE_URLENCODE, $encoding); |
47 | 47 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | ->getInfo() |
44 | 44 | ->getStringLiterals(); |
45 | 45 | |
46 | - foreach($literals as $literal) |
|
46 | + foreach ($literals as $literal) |
|
47 | 47 | { |
48 | 48 | $text = $literal->getText(); |
49 | 49 | |
50 | - if(strpos($text, '=') !== false && $this->analyzeQueryString($text)) |
|
50 | + if (strpos($text, '=') !== false && $this->analyzeQueryString($text)) |
|
51 | 51 | { |
52 | 52 | $this->queryParamTokens[] = $literal; |
53 | 53 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | public function getQueryParam(string $name) : string |
90 | 90 | { |
91 | - if(isset($this->queryParams[$name])) |
|
91 | + if (isset($this->queryParams[$name])) |
|
92 | 92 | { |
93 | 93 | return $this->queryParams[$name]; |
94 | 94 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | public function removeQueryParam(string $name) : self |
111 | 111 | { |
112 | - if(isset($this->queryParams[$name])) |
|
112 | + if (isset($this->queryParams[$name])) |
|
113 | 113 | { |
114 | 114 | unset($this->queryParams[$name]); |
115 | 115 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function setEncodingEnabled(string $keyword, bool $enabled) : self |
54 | 54 | { |
55 | - if(!$this->supportsEncoding($keyword)) |
|
55 | + if (!$this->supportsEncoding($keyword)) |
|
56 | 56 | { |
57 | 57 | throw new Mailcode_Exception( |
58 | 58 | 'Cannot set encoding status, command does not support target encoding.', |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | $name = $keyword->getKeyword(); |
88 | 88 | |
89 | - if($this->supportsEncoding($name) && $this->isEncodingEnabled($name)) |
|
89 | + if ($this->supportsEncoding($name) && $this->isEncodingEnabled($name)) |
|
90 | 90 | { |
91 | 91 | $result[] = $name; |
92 | 92 | } |
@@ -99,22 +99,22 @@ discard block |
||
99 | 99 | { |
100 | 100 | $encodings = array(); |
101 | 101 | |
102 | - if($this instanceof IDNEncodeInterface) |
|
102 | + if ($this instanceof IDNEncodeInterface) |
|
103 | 103 | { |
104 | 104 | $encodings[] = Mailcode_Commands_Keywords::TYPE_IDN_ENCODE; |
105 | 105 | } |
106 | 106 | |
107 | - if($this instanceof IDNDecodeInterface) |
|
107 | + if ($this instanceof IDNDecodeInterface) |
|
108 | 108 | { |
109 | 109 | $encodings[] = Mailcode_Commands_Keywords::TYPE_IDN_DECODE; |
110 | 110 | } |
111 | 111 | |
112 | - if($this instanceof Mailcode_Interfaces_Commands_Validation_URLEncode) |
|
112 | + if ($this instanceof Mailcode_Interfaces_Commands_Validation_URLEncode) |
|
113 | 113 | { |
114 | 114 | $encodings[] = Mailcode_Commands_Keywords::TYPE_URLENCODE; |
115 | 115 | } |
116 | 116 | |
117 | - if($this instanceof Mailcode_Interfaces_Commands_Validation_URLDecode) |
|
117 | + if ($this instanceof Mailcode_Interfaces_Commands_Validation_URLDecode) |
|
118 | 118 | { |
119 | 119 | $encodings[] = Mailcode_Commands_Keywords::TYPE_URLDECODE; |
120 | 120 | } |
@@ -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:').' '. |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | abstract class Mailcode_Translator_Syntax_ApacheVelocity extends Mailcode_Translator_Command |
24 | 24 | { |
25 | 25 | /** |
26 | - * @var string[] |
|
27 | - */ |
|
26 | + * @var string[] |
|
27 | + */ |
|
28 | 28 | private array $regexSpecialChars = array( |
29 | 29 | '?', |
30 | 30 | '.', |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | - * Filters the string for use in an Apache Velocity (Java) |
|
53 | - * regex string: escapes all special characters. |
|
54 | - * |
|
55 | - * Velocity does its own escaping, so no need to escape special |
|
56 | - * characters as if they were a javascript string. |
|
57 | - * |
|
58 | - * @param string $string |
|
59 | - * @return string |
|
60 | - */ |
|
52 | + * Filters the string for use in an Apache Velocity (Java) |
|
53 | + * regex string: escapes all special characters. |
|
54 | + * |
|
55 | + * Velocity does its own escaping, so no need to escape special |
|
56 | + * characters as if they were a javascript string. |
|
57 | + * |
|
58 | + * @param string $string |
|
59 | + * @return string |
|
60 | + */ |
|
61 | 61 | public function filterRegexString(string $string) : string |
62 | 62 | { |
63 | 63 | // Special case: previously escaped quotes. |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | // All other special characters have to be escaped |
73 | 73 | // with two backslashes. |
74 | - foreach($this->regexSpecialChars as $char) |
|
74 | + foreach ($this->regexSpecialChars as $char) |
|
75 | 75 | { |
76 | 76 | $string = str_replace($char, '\\'.$char, $string); |
77 | 77 | } |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | |
86 | 86 | protected function addURLEncoding(Mailcode_Commands_Command $command, string $statement) : string |
87 | 87 | { |
88 | - if(!$command instanceof URLEncodingInterface) |
|
88 | + if (!$command instanceof URLEncodingInterface) |
|
89 | 89 | { |
90 | 90 | return $statement; |
91 | 91 | } |
92 | 92 | |
93 | - if($command->isURLEncoded()) |
|
93 | + if ($command->isURLEncoded()) |
|
94 | 94 | { |
95 | 95 | return sprintf( |
96 | 96 | '${esc.url($%s)}', |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
101 | - if($command->isURLDecoded()) |
|
101 | + if ($command->isURLDecoded()) |
|
102 | 102 | { |
103 | 103 | return sprintf( |
104 | 104 | '${esc.unurl($%s)}', |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | { |
117 | 117 | $varName = '$'.ltrim($varName, '$'); |
118 | 118 | |
119 | - if($absolute) |
|
119 | + if ($absolute) |
|
120 | 120 | { |
121 | 121 | $varName = sprintf('${price.abs(%s)}', $varName); |
122 | 122 | } |
@@ -17,16 +17,16 @@ |
||
17 | 17 | $statements = array(); |
18 | 18 | $statements[] = $this->renderURL($command); |
19 | 19 | |
20 | - if($command->isTrackingEnabled()) |
|
20 | + if ($command->isTrackingEnabled()) |
|
21 | 21 | { |
22 | 22 | $statements[] = $this->renderTracking($command); |
23 | 23 | } |
24 | 24 | |
25 | - if($command->hasQueryParams()) |
|
25 | + if ($command->hasQueryParams()) |
|
26 | 26 | { |
27 | 27 | $params = $command->getQueryParams(); |
28 | 28 | |
29 | - foreach($params as $name => $value) |
|
29 | + foreach ($params as $name => $value) |
|
30 | 30 | { |
31 | 31 | $statements[] = $this->renderQueryParam($name, $value); |
32 | 32 | } |