@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $tagName = strtolower($tagName); |
| 44 | 44 | |
| 45 | - if(!in_array($tagName, $this->excludeTags)) |
|
| 45 | + if (!in_array($tagName, $this->excludeTags)) |
|
| 46 | 46 | { |
| 47 | 47 | $this->excludeTags[] = $tagName; |
| 48 | 48 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function excludeTags(array $tagNames) |
| 60 | 60 | { |
| 61 | - foreach($tagNames as $tagName) |
|
| 61 | + foreach ($tagNames as $tagName) |
|
| 62 | 62 | { |
| 63 | 63 | $this->excludeTag((string)$tagName); |
| 64 | 64 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | $pos = $this->getStartPosition(); |
| 55 | 55 | |
| 56 | - if(is_bool($pos)) |
|
| 56 | + if (is_bool($pos)) |
|
| 57 | 57 | { |
| 58 | 58 | return ''; |
| 59 | 59 | } |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | { |
| 76 | 76 | $tagNames = $this->getParentTags(); |
| 77 | 77 | |
| 78 | - foreach($tagNames as $tagName) |
|
| 78 | + foreach ($tagNames as $tagName) |
|
| 79 | 79 | { |
| 80 | - if($this->formatter->isTagExcluded($tagName)) |
|
| 80 | + if ($this->formatter->isTagExcluded($tagName)) |
|
| 81 | 81 | { |
| 82 | 82 | return true; |
| 83 | 83 | } |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | // Create a stack of all direct parent tags of the command. |
| 100 | 100 | // Handles closing tags as well. |
| 101 | 101 | $stack = array(); |
| 102 | - foreach($tags[2] as $idx => $tagName) |
|
| 102 | + foreach ($tags[2] as $idx => $tagName) |
|
| 103 | 103 | { |
| 104 | 104 | $closing = $tags[1][$idx] === '/'; |
| 105 | 105 | |
| 106 | - if($closing) |
|
| 106 | + if ($closing) |
|
| 107 | 107 | { |
| 108 | 108 | array_pop($stack); |
| 109 | 109 | } |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | // This check is easy: if the command is in the attribute |
| 130 | 130 | // of any of the tags, we will find the command marker in there. |
| 131 | - foreach($tags[3] as $attributes) |
|
| 131 | + foreach ($tags[3] as $attributes) |
|
| 132 | 132 | { |
| 133 | - if(strstr($attributes, self::COMMAND_MARKER)) |
|
| 133 | + if (strstr($attributes, self::COMMAND_MARKER)) |
|
| 134 | 134 | { |
| 135 | 135 | return true; |
| 136 | 136 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | private function getTagAncestry() : array |
| 149 | 149 | { |
| 150 | - if($this->ancestryChecked) |
|
| 150 | + if ($this->ancestryChecked) |
|
| 151 | 151 | { |
| 152 | 152 | return $this->tagAncestry; |
| 153 | 153 | } |
@@ -89,23 +89,23 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $placeholderID = $this->placeholder->getID(); |
| 91 | 91 | |
| 92 | - foreach($placeholders as $placeholder) |
|
| 92 | + foreach ($placeholders as $placeholder) |
|
| 93 | 93 | { |
| 94 | - if($placeholder->getID() === $placeholderID) |
|
| 94 | + if ($placeholder->getID() === $placeholderID) |
|
| 95 | 95 | { |
| 96 | 96 | continue; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $start = $this->subject->getSubstrPosition($placeholder->getReplacementText()); |
| 100 | 100 | |
| 101 | - if($start === false) |
|
| 101 | + if ($start === false) |
|
| 102 | 102 | { |
| 103 | 103 | continue; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $end = $start + $placeholder->getReplacementLength(); |
| 107 | 107 | |
| 108 | - if($position >= $start && $position <= $end) |
|
| 108 | + if ($position >= $start && $position <= $end) |
|
| 109 | 109 | { |
| 110 | 110 | return true; |
| 111 | 111 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | $start = $this->getStartPosition(); |
| 123 | 123 | |
| 124 | - if($start !== false) |
|
| 124 | + if ($start !== false) |
|
| 125 | 125 | { |
| 126 | 126 | return $start + $this->placeholder->getReplacementLength(); |
| 127 | 127 | } |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | { |
| 152 | 152 | $needle = $this->placeholder->getReplacementText(); |
| 153 | 153 | |
| 154 | - if($this->subject->replaceSubstrings($needle, $replacementText)) |
|
| 154 | + if ($this->subject->replaceSubstrings($needle, $replacementText)) |
|
| 155 | 155 | { |
| 156 | 156 | return; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // Complain about missing placeholders only if we |
| 160 | 160 | // are not in partial mode. |
| 161 | - if(!$this->formatter->getFormatting()->isPartial()) |
|
| 161 | + if (!$this->formatter->getFormatting()->isPartial()) |
|
| 162 | 162 | { |
| 163 | 163 | throw new Mailcode_Exception( |
| 164 | 164 | 'Could not find the placeholder to replace', |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | public function format() : void |
| 175 | 175 | { |
| 176 | - if($this->requiresAdjustment() && (!empty($this->prepend) || !empty($this->append))) |
|
| 176 | + if ($this->requiresAdjustment() && (!empty($this->prepend) || !empty($this->append))) |
|
| 177 | 177 | { |
| 178 | 178 | $this->replaceWith(sprintf( |
| 179 | 179 | '%s%s%s', |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard |
| 128 | 128 | { |
| 129 | - if(empty($delimiter)) |
|
| 129 | + if (empty($delimiter)) |
|
| 130 | 130 | { |
| 131 | 131 | throw new Mailcode_Exception( |
| 132 | 132 | 'Empty delimiter', |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | $placeholders = $this->getPlaceholders(); |
| 177 | 177 | $string = $this->originalString; |
| 178 | 178 | |
| 179 | - foreach($placeholders as $placeholder) |
|
| 179 | + foreach ($placeholders as $placeholder) |
|
| 180 | 180 | { |
| 181 | 181 | $pos = mb_strpos($string, $placeholder->getOriginalText()); |
| 182 | 182 | |
| 183 | - if($pos === false) |
|
| 183 | + if ($pos === false) |
|
| 184 | 184 | { |
| 185 | 185 | throw new Mailcode_Exception( |
| 186 | 186 | 'Placeholder original text not found', |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting |
| 211 | 211 | { |
| 212 | - if(is_string($subject)) |
|
| 212 | + if (is_string($subject)) |
|
| 213 | 213 | { |
| 214 | 214 | $subject = Mailcode::create()->createString($subject); |
| 215 | 215 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | public function getPlaceholders() |
| 227 | 227 | { |
| 228 | - if(isset($this->placeholders)) |
|
| 228 | + if (isset($this->placeholders)) |
|
| 229 | 229 | { |
| 230 | 230 | return $this->placeholders; |
| 231 | 231 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | $cmds = $this->getCollection()->getCommands(); |
| 236 | 236 | |
| 237 | - foreach($cmds as $command) |
|
| 237 | + foreach ($cmds as $command) |
|
| 238 | 238 | { |
| 239 | 239 | self::$counter++; |
| 240 | 240 | |
@@ -248,21 +248,21 @@ discard block |
||
| 248 | 248 | return $this->placeholders; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - protected function restore(string $string, bool $partial=false, bool $highlighted=false) : string |
|
| 251 | + protected function restore(string $string, bool $partial = false, bool $highlighted = false) : string |
|
| 252 | 252 | { |
| 253 | - if(!$partial) |
|
| 253 | + if (!$partial) |
|
| 254 | 254 | { |
| 255 | 255 | $this->requireValidCollection(); |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | $formatting = $this->createFormatting($string); |
| 259 | 259 | |
| 260 | - if($partial) |
|
| 260 | + if ($partial) |
|
| 261 | 261 | { |
| 262 | 262 | $formatting->makePartial(); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - if($highlighted) |
|
| 265 | + if ($highlighted) |
|
| 266 | 266 | { |
| 267 | 267 | $formatting->replaceWithHTMLHighlighting(); |
| 268 | 268 | } |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | */ |
| 359 | 359 | public function getCollection() : Mailcode_Collection |
| 360 | 360 | { |
| 361 | - if(isset($this->collection)) |
|
| 361 | + if (isset($this->collection)) |
|
| 362 | 362 | { |
| 363 | 363 | return $this->collection; |
| 364 | 364 | } |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | */ |
| 381 | 381 | protected function requireValidCollection() : void |
| 382 | 382 | { |
| 383 | - if($this->getCollection()->isValid()) |
|
| 383 | + if ($this->getCollection()->isValid()) |
|
| 384 | 384 | { |
| 385 | 385 | return; |
| 386 | 386 | } |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | */ |
| 404 | 404 | public function getPlaceholderStrings() : array |
| 405 | 405 | { |
| 406 | - if(is_array($this->placeholderStrings)) |
|
| 406 | + if (is_array($this->placeholderStrings)) |
|
| 407 | 407 | { |
| 408 | 408 | return $this->placeholderStrings; |
| 409 | 409 | } |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | |
| 413 | 413 | $this->placeholderStrings = array(); |
| 414 | 414 | |
| 415 | - foreach($placeholders as $placeholder) |
|
| 415 | + foreach ($placeholders as $placeholder) |
|
| 416 | 416 | { |
| 417 | 417 | $this->placeholderStrings[] = $placeholder->getReplacementText(); |
| 418 | 418 | } |
@@ -438,9 +438,9 @@ discard block |
||
| 438 | 438 | { |
| 439 | 439 | $placeholders = $this->getPlaceholders(); |
| 440 | 440 | |
| 441 | - foreach($placeholders as $placeholder) |
|
| 441 | + foreach ($placeholders as $placeholder) |
|
| 442 | 442 | { |
| 443 | - if($placeholder->getID() === $id) |
|
| 443 | + if ($placeholder->getID() === $id) |
|
| 444 | 444 | { |
| 445 | 445 | return $placeholder; |
| 446 | 446 | } |
@@ -467,9 +467,9 @@ discard block |
||
| 467 | 467 | { |
| 468 | 468 | $placeholders = $this->getPlaceholders(); |
| 469 | 469 | |
| 470 | - foreach($placeholders as $placeholder) |
|
| 470 | + foreach ($placeholders as $placeholder) |
|
| 471 | 471 | { |
| 472 | - if($placeholder->getReplacementText() === $string) |
|
| 472 | + if ($placeholder->getReplacementText() === $string) |
|
| 473 | 473 | { |
| 474 | 474 | return $placeholder; |
| 475 | 475 | } |