@@ -56,23 +56,23 @@ |
||
56 | 56 | |
57 | 57 | private function analyzeURL(string $url) : void |
58 | 58 | { |
59 | - if(stristr($url, 'tel:') !== false) |
|
59 | + if (stristr($url, 'tel:') !== false) |
|
60 | 60 | { |
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | 64 | $placeholders = $this->safeguard->getPlaceholdersCollection()->getAll(); |
65 | 65 | |
66 | - foreach($placeholders as $placeholder) |
|
66 | + foreach ($placeholders as $placeholder) |
|
67 | 67 | { |
68 | 68 | $command = $placeholder->getCommand(); |
69 | 69 | |
70 | - if(!$command->supportsURLEncoding()) |
|
70 | + if (!$command->supportsURLEncoding()) |
|
71 | 71 | { |
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | |
75 | - if(strstr($url, $placeholder->getReplacementText()) !== false && !$command->isURLDecoded()) |
|
75 | + if (strstr($url, $placeholder->getReplacementText()) !== false && !$command->isURLDecoded()) |
|
76 | 76 | { |
77 | 77 | $command->setURLEncoding(true); |
78 | 78 | break; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getByIndex(int $index) : Mailcode_Parser_Safeguard_Placeholder |
41 | 41 | { |
42 | - if(isset($this->placeholders[$index])) |
|
42 | + if (isset($this->placeholders[$index])) |
|
43 | 43 | { |
44 | 44 | return $this->placeholders[$index]; |
45 | 45 | } |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | public function getByCommand(Mailcode_Commands_Command $command) : Mailcode_Parser_Safeguard_Placeholder |
55 | 55 | { |
56 | - foreach($this->placeholders as $placeholder) |
|
56 | + foreach ($this->placeholders as $placeholder) |
|
57 | 57 | { |
58 | - if($placeholder->getCommand() === $command) |
|
58 | + if ($placeholder->getCommand() === $command) |
|
59 | 59 | { |
60 | 60 | return $placeholder; |
61 | 61 | } |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function getByID(int $id) : Mailcode_Parser_Safeguard_Placeholder |
79 | 79 | { |
80 | - foreach($this->placeholders as $placeholder) |
|
80 | + foreach ($this->placeholders as $placeholder) |
|
81 | 81 | { |
82 | - if($placeholder->getID() === $id) |
|
82 | + if ($placeholder->getID() === $id) |
|
83 | 83 | { |
84 | 84 | return $placeholder; |
85 | 85 | } |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function getByString(string $string) : Mailcode_Parser_Safeguard_Placeholder |
106 | 106 | { |
107 | - foreach($this->placeholders as $placeholder) |
|
107 | + foreach ($this->placeholders as $placeholder) |
|
108 | 108 | { |
109 | - if($placeholder->getReplacementText() === $string) |
|
109 | + if ($placeholder->getReplacementText() === $string) |
|
110 | 110 | { |
111 | 111 | return $placeholder; |
112 | 112 | } |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function getStrings() : array |
131 | 131 | { |
132 | - if(is_array($this->placeholderStrings)) |
|
132 | + if (is_array($this->placeholderStrings)) |
|
133 | 133 | { |
134 | 134 | return $this->placeholderStrings; |
135 | 135 | } |
136 | 136 | |
137 | 137 | $this->placeholderStrings = array(); |
138 | 138 | |
139 | - foreach($this->placeholders as $placeholder) |
|
139 | + foreach ($this->placeholders as $placeholder) |
|
140 | 140 | { |
141 | 141 | $this->placeholderStrings[] = $placeholder->getReplacementText(); |
142 | 142 | } |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | { |
114 | 114 | $result = array(); |
115 | 115 | |
116 | - foreach($this->tokensOrdered as $token) |
|
116 | + foreach ($this->tokensOrdered as $token) |
|
117 | 117 | { |
118 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
118 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
119 | 119 | { |
120 | 120 | $result[] = $token; |
121 | 121 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | { |
129 | 129 | $unknown = $this->getUnknown(); |
130 | 130 | |
131 | - if(!empty($unknown)) |
|
131 | + if (!empty($unknown)) |
|
132 | 132 | { |
133 | 133 | return array_shift($unknown); |
134 | 134 | } |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | { |
141 | 141 | $parts = array(); |
142 | 142 | |
143 | - foreach($this->tokensOrdered as $token) |
|
143 | + foreach ($this->tokensOrdered as $token) |
|
144 | 144 | { |
145 | 145 | $string = $token->getNormalized(); |
146 | 146 | |
147 | - if($string !== '') |
|
147 | + if ($string !== '') |
|
148 | 148 | { |
149 | 149 | $parts[] = $string; |
150 | 150 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $statement = trim($statement); |
169 | 169 | $tokens = array(); |
170 | 170 | |
171 | - foreach($this->tokenCategories as $tokenCategory) |
|
171 | + foreach ($this->tokenCategories as $tokenCategory) |
|
172 | 172 | { |
173 | 173 | $processor = $this->createProcessor($tokenCategory, $statement, $tokens); |
174 | 174 | $processor->process(); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | $instance = new $class($this, $statement, $tokens); |
196 | 196 | |
197 | - if($instance instanceof Mailcode_Parser_Statement_Tokenizer_Process) |
|
197 | + if ($instance instanceof Mailcode_Parser_Statement_Tokenizer_Process) |
|
198 | 198 | { |
199 | 199 | return $instance; |
200 | 200 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param mixed $subject |
216 | 216 | * @return Mailcode_Parser_Statement_Tokenizer_Token |
217 | 217 | */ |
218 | - public function createToken(string $type, string $matchedText, $subject=null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
218 | + public function createToken(string $type, string $matchedText, $subject = null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
219 | 219 | { |
220 | 220 | $tokenID = $this->generateID(); |
221 | 221 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | $token = new $class($tokenID, $matchedText, $subject, $this->getSourceCommand()); |
225 | 225 | |
226 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token) |
|
226 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token) |
|
227 | 227 | { |
228 | 228 | return $token; |
229 | 229 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | $token = $this->appendToken('Keyword', $name); |
246 | 246 | |
247 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
247 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
248 | 248 | { |
249 | 249 | return $token; |
250 | 250 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | |
264 | 264 | foreach ($this->tokensOrdered as $checkToken) |
265 | 265 | { |
266 | - if($checkToken->getID() !== $tokenID) |
|
266 | + if ($checkToken->getID() !== $tokenID) |
|
267 | 267 | { |
268 | 268 | $keep[] = $checkToken; |
269 | 269 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param mixed $subject |
283 | 283 | * @return Mailcode_Parser_Statement_Tokenizer_Token |
284 | 284 | */ |
285 | - protected function appendToken(string $type, string $matchedText, $subject=null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
285 | + protected function appendToken(string $type, string $matchedText, $subject = null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
286 | 286 | { |
287 | 287 | $token = $this->createToken($type, $matchedText, $subject); |
288 | 288 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | { |
305 | 305 | static $alphas; |
306 | 306 | |
307 | - if(!isset($alphas)) |
|
307 | + if (!isset($alphas)) |
|
308 | 308 | { |
309 | 309 | $alphas = range('A', 'Z'); |
310 | 310 | } |
@@ -313,12 +313,12 @@ discard block |
||
313 | 313 | |
314 | 314 | $result = ''; |
315 | 315 | |
316 | - for($i=0; $i < $amount; $i++) |
|
316 | + for ($i = 0; $i < $amount; $i++) |
|
317 | 317 | { |
318 | 318 | $result .= $alphas[array_rand($alphas)]; |
319 | 319 | } |
320 | 320 | |
321 | - if(!in_array($result, self::$ids)) |
|
321 | + if (!in_array($result, self::$ids)) |
|
322 | 322 | { |
323 | 323 | self::$ids[] = $result; |
324 | 324 | return $result; |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | */ |
46 | 46 | private ?Mailcode_Factory_CommandSets_Set_ElseIf $elseIf = null; |
47 | 47 | |
48 | - public function if() : Mailcode_Factory_CommandSets_Set_If |
|
48 | + public function if () : Mailcode_Factory_CommandSets_Set_If |
|
49 | 49 | { |
50 | - if(!isset($this->if)) |
|
50 | + if (!isset($this->if)) |
|
51 | 51 | { |
52 | 52 | $this->if = new Mailcode_Factory_CommandSets_Set_If(); |
53 | 53 | } |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | return $this->if; |
56 | 56 | } |
57 | 57 | |
58 | - public function elseIf() : Mailcode_Factory_CommandSets_Set_ElseIf |
|
58 | + public function elseIf () : Mailcode_Factory_CommandSets_Set_ElseIf |
|
59 | 59 | { |
60 | - if(!isset($this->elseIf)) |
|
60 | + if (!isset($this->elseIf)) |
|
61 | 61 | { |
62 | 62 | $this->elseIf = new Mailcode_Factory_CommandSets_Set_ElseIf(); |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | public function show() : Mailcode_Factory_CommandSets_Set_Show |
69 | 69 | { |
70 | - if(!isset($this->show)) |
|
70 | + if (!isset($this->show)) |
|
71 | 71 | { |
72 | 72 | $this->show = new Mailcode_Factory_CommandSets_Set_Show(); |
73 | 73 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | public function misc() : Mailcode_Factory_CommandSets_Set_Misc |
79 | 79 | { |
80 | - if(!isset($this->misc)) |
|
80 | + if (!isset($this->misc)) |
|
81 | 81 | { |
82 | 82 | $this->misc = new Mailcode_Factory_CommandSets_Set_Misc(); |
83 | 83 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | public function set() : Mailcode_Factory_CommandSets_Set_Set |
89 | 89 | { |
90 | - if(!isset($this->set)) |
|
90 | + if (!isset($this->set)) |
|
91 | 91 | { |
92 | 92 | $this->set = new Mailcode_Factory_CommandSets_Set_Set(); |
93 | 93 | } |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | |
39 | 39 | $keywords = $this->params->getInfo()->getKeywords(); |
40 | 40 | |
41 | - foreach($keywords as $keyword) |
|
41 | + foreach ($keywords as $keyword) |
|
42 | 42 | { |
43 | - if($keyword->isNoHTML()) |
|
43 | + if ($keyword->isNoHTML()) |
|
44 | 44 | { |
45 | 45 | $this->noHTMLToken = $keyword; |
46 | 46 | break; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return $this |
56 | 56 | * @throws Mailcode_Exception |
57 | 57 | */ |
58 | - public function setHTMLEnabled(bool $enabled=true) : self |
|
58 | + public function setHTMLEnabled(bool $enabled = true) : self |
|
59 | 59 | { |
60 | 60 | $this->params->getInfo()->setKeywordEnabled(Mailcode_Commands_Keywords::TYPE_NOHTML, !$enabled); |
61 | 61 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ->getInfo() |
38 | 38 | ->getTokenByIndex(0); |
39 | 39 | |
40 | - if($contentIDToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) |
|
40 | + if ($contentIDToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) |
|
41 | 41 | { |
42 | 42 | $this->contentIDToken = $contentIDToken; |
43 | 43 | $this->loadContent(); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | public function getContentID() : int |
54 | 54 | { |
55 | - if(isset($this->contentIDToken)) |
|
55 | + if (isset($this->contentIDToken)) |
|
56 | 56 | { |
57 | 57 | return (int)$this->contentIDToken->getValue(); |
58 | 58 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | $result = new Mailcode_Parser_ParseResult($collection, $preParser); |
71 | 71 | |
72 | - if(!$collection->isValid()) |
|
72 | + if (!$collection->isValid()) |
|
73 | 73 | { |
74 | 74 | return $result; |
75 | 75 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | $total = count($matches[0]); |
83 | 83 | |
84 | - for($i=0; $i < $total; $i++) |
|
84 | + for ($i = 0; $i < $total; $i++) |
|
85 | 85 | { |
86 | 86 | $match = $this->parseMatch($matches, $i); |
87 | 87 | |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | private function handleNesting(Mailcode_Commands_Command $cmd) : void |
152 | 152 | { |
153 | 153 | // Set the command's parent from the stack, if any is present. |
154 | - if(!empty($this->stack)) |
|
154 | + if (!empty($this->stack)) |
|
155 | 155 | { |
156 | 156 | $cmd->setParent($this->getStackLast()); |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Handle opening and closing commands, adding and removing from the stack. |
160 | - if($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
|
160 | + if ($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
|
161 | 161 | { |
162 | 162 | $this->stack[] = $cmd; |
163 | 163 | } |
164 | - else if($cmd instanceof Mailcode_Commands_Command_Type_Closing) |
|
164 | + else if ($cmd instanceof Mailcode_Commands_Command_Type_Closing) |
|
165 | 165 | { |
166 | 166 | array_pop($this->stack); |
167 | 167 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | { |
176 | 176 | $cmd = $this->stack[array_key_last($this->stack)]; |
177 | 177 | |
178 | - if($cmd instanceof Mailcode_Commands_Command) |
|
178 | + if ($cmd instanceof Mailcode_Commands_Command) |
|
179 | 179 | { |
180 | 180 | return $cmd; |
181 | 181 | } |
@@ -204,16 +204,16 @@ discard block |
||
204 | 204 | // 5 = parameter type command, type |
205 | 205 | // 6 = parameter type command, params |
206 | 206 | |
207 | - if(!empty($matches[1][$index])) |
|
207 | + if (!empty($matches[1][$index])) |
|
208 | 208 | { |
209 | 209 | $name = $matches[1][$index]; |
210 | 210 | } |
211 | - else if(!empty($matches[2][$index])) |
|
211 | + else if (!empty($matches[2][$index])) |
|
212 | 212 | { |
213 | 213 | $name = $matches[2][$index]; |
214 | 214 | $params = $matches[3][$index]; |
215 | 215 | } |
216 | - else if(!empty($matches[4][$index])) |
|
216 | + else if (!empty($matches[4][$index])) |
|
217 | 217 | { |
218 | 218 | $name = $matches[4][$index]; |
219 | 219 | $type = $matches[5][$index]; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param Mailcode_Commands_Command|null $sourceCommand |
251 | 251 | * @return Mailcode_Parser_Statement |
252 | 252 | */ |
253 | - public function createStatement(string $statement, bool $freeform=false, ?Mailcode_Commands_Command $sourceCommand=null) : Mailcode_Parser_Statement |
|
253 | + public function createStatement(string $statement, bool $freeform = false, ?Mailcode_Commands_Command $sourceCommand = null) : Mailcode_Parser_Statement |
|
254 | 254 | { |
255 | 255 | return new Mailcode_Parser_Statement($statement, $freeform, $sourceCommand); |
256 | 256 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $command->getID() |
64 | 64 | ); |
65 | 65 | |
66 | - if(!class_exists($class)) |
|
66 | + if (!class_exists($class)) |
|
67 | 67 | { |
68 | 68 | throw new Mailcode_Translator_Exception( |
69 | 69 | sprintf('Unknown command %s in translator', $command->getID()), |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | $translator = new $class($command); |
79 | 79 | |
80 | - if($translator instanceof Mailcode_Translator_Command) |
|
80 | + if ($translator instanceof Mailcode_Translator_Command) |
|
81 | 81 | { |
82 | 82 | return $translator; |
83 | 83 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | { |
106 | 106 | $subject = $safeguard->makeSafe(); |
107 | 107 | |
108 | - if(!$safeguard->hasPlaceholders()) |
|
108 | + if (!$safeguard->hasPlaceholders()) |
|
109 | 109 | { |
110 | 110 | return $subject; |
111 | 111 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | $replaces = array(); |
116 | 116 | |
117 | - foreach($placeholders as $placeholder) |
|
117 | + foreach ($placeholders as $placeholder) |
|
118 | 118 | { |
119 | 119 | $command = $placeholder->getCommand(); |
120 | 120 |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | { |
55 | 55 | $internalFormat = $command->getTranslationParam('internal_format'); |
56 | 56 | |
57 | - if(is_string($internalFormat) && !empty($internalFormat)) |
|
57 | + if (is_string($internalFormat) && !empty($internalFormat)) |
|
58 | 58 | { |
59 | 59 | return $internalFormat; |
60 | 60 | } |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | $chars = ConvertHelper::string2array($formatString); |
84 | 84 | $result = array(); |
85 | 85 | |
86 | - foreach($chars as $char) |
|
86 | + foreach ($chars as $char) |
|
87 | 87 | { |
88 | - if(!isset($this->charTable[$char])) |
|
88 | + if (!isset($this->charTable[$char])) |
|
89 | 89 | { |
90 | 90 | throw new Mailcode_Translator_Exception( |
91 | 91 | 'Unknown date format string character', |