@@ -35,13 +35,13 @@ |
||
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Resolves the string with which this location needs to be |
|
| 40 | - * replaced. |
|
| 41 | - * |
|
| 42 | - * @param Mailcode_Parser_Safeguard_Formatter_Location $location |
|
| 43 | - * @return string |
|
| 44 | - */ |
|
| 38 | + /** |
|
| 39 | + * Resolves the string with which this location needs to be |
|
| 40 | + * replaced. |
|
| 41 | + * |
|
| 42 | + * @param Mailcode_Parser_Safeguard_Formatter_Location $location |
|
| 43 | + * @return string |
|
| 44 | + */ |
|
| 45 | 45 | private function resolveReplacement(Mailcode_Parser_Safeguard_Formatter_Location $location) : string |
| 46 | 46 | { |
| 47 | 47 | if($location->requiresAdjustment()) |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | $locations = $this->resolveLocations(); |
| 31 | 31 | |
| 32 | - foreach($locations as $location) |
|
| 32 | + foreach ($locations as $location) |
|
| 33 | 33 | { |
| 34 | 34 | $location->replaceWith($this->resolveReplacement($location)); |
| 35 | 35 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | private function resolveReplacement(Mailcode_Parser_Safeguard_Formatter_Location $location) : string |
| 48 | 48 | { |
| 49 | - if($location->requiresAdjustment()) |
|
| 49 | + if ($location->requiresAdjustment()) |
|
| 50 | 50 | { |
| 51 | 51 | return $this->getReplaceString($location); |
| 52 | 52 | } |
@@ -23,14 +23,14 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class Mailcode_Parser_Safeguard_Formatter_Type_SingleLines extends Mailcode_Parser_Safeguard_Formatter_FormatType |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 26 | + /** |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | 29 | private $eol; |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var int |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var int |
|
| 33 | + */ |
|
| 34 | 34 | private $eolLength; |
| 35 | 35 | |
| 36 | 36 | protected function initFormatting() : void |
@@ -25,14 +25,14 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | class Mailcode_Parser_Safeguard_Formatter_Type_SingleLines_Location extends Mailcode_Parser_Safeguard_Formatter_Location |
| 27 | 27 | { |
| 28 | - /** |
|
| 29 | - * @var int |
|
| 30 | - */ |
|
| 28 | + /** |
|
| 29 | + * @var int |
|
| 30 | + */ |
|
| 31 | 31 | protected $eolLength; |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 33 | + /** |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | 36 | protected $eol; |
| 37 | 37 | |
| 38 | 38 | protected function init() : void |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $position = $this->getStartPosition(); |
| 56 | 56 | |
| 57 | 57 | // we're at the beginning of the string |
| 58 | - if($position === false || $position === 0) |
|
| 58 | + if ($position === false || $position === 0) |
|
| 59 | 59 | { |
| 60 | 60 | $this->log(sprintf( |
| 61 | 61 | 'Prepend: NO | Position: [%s] | Not found, or at beginning of string.', |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | $prevPos = $position - $this->eolLength; |
| 69 | 69 | |
| 70 | - if($prevPos < 0) |
|
| 70 | + if ($prevPos < 0) |
|
| 71 | 71 | { |
| 72 | 72 | $prevPos = 0; |
| 73 | 73 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | protected function checkPreviousPosition(int $prevPos) : void |
| 79 | 79 | { |
| 80 | - if($this->isWithinCommand($prevPos)) |
|
| 80 | + if ($this->isWithinCommand($prevPos)) |
|
| 81 | 81 | { |
| 82 | 82 | $this->log(sprintf( |
| 83 | 83 | 'Prepend: NO | Position: [%s] | Is within a mailcode command.', |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $match = $this->subject->getSubstr($prevPos, $this->eolLength); |
| 91 | 91 | |
| 92 | - if($match !== $this->formatter->getEOLChar()) |
|
| 92 | + if ($match !== $this->formatter->getEOLChar()) |
|
| 93 | 93 | { |
| 94 | 94 | $this->log(sprintf( |
| 95 | 95 | 'Prepend: YES | Position: [%s] | Characters: [%s] | Do not match the EOL character.', |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $position = $this->getEndPosition(); |
| 109 | 109 | |
| 110 | 110 | // we're at the end of the string |
| 111 | - if($position === false || $position >= $subjectLength) |
|
| 111 | + if ($position === false || $position >= $subjectLength) |
|
| 112 | 112 | { |
| 113 | 113 | $this->log(sprintf( |
| 114 | 114 | 'Append: NO | Position: [%s] | End of string, or too long | Subject length: [%s]', |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | $nextPos = $position + $this->eolLength; |
| 123 | 123 | |
| 124 | - if($nextPos > $subjectLength) |
|
| 124 | + if ($nextPos > $subjectLength) |
|
| 125 | 125 | { |
| 126 | 126 | $nextPos = $subjectLength - $this->eolLength; |
| 127 | 127 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | protected function checkNextPosition(int $nextPos) : void |
| 133 | 133 | { |
| 134 | - if($this->isWithinCommand($nextPos)) |
|
| 134 | + if ($this->isWithinCommand($nextPos)) |
|
| 135 | 135 | { |
| 136 | 136 | $this->log(sprintf( |
| 137 | 137 | 'Append: YES | Position: [%s] | Is within a mailcode command.', |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | $next = $this->subject->getSubstr($nextPos, $this->eolLength); |
| 147 | 147 | |
| 148 | - if($next !== $this->formatter->getEOLChar()) |
|
| 148 | + if ($next !== $this->formatter->getEOLChar()) |
|
| 149 | 149 | { |
| 150 | 150 | $this->log(sprintf( |
| 151 | 151 | 'Append: YES | Position: [%s] | Next characters: [%s] | Do not match the EOL character.', |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | |
| 33 | 33 | public function requiresAdjustment(): bool |
| 34 | 34 | { |
| 35 | - if(!parent::requiresAdjustment()) |
|
| 35 | + if (!parent::requiresAdjustment()) |
|
| 36 | 36 | { |
| 37 | 37 | return false; |
| 38 | 38 | } |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | const COMMAND_MARKER = '__MAILCODE_COMMAND__'; |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var boolean |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * @var boolean |
|
| 29 | + */ |
|
| 30 | 30 | private $ancestryChecked = false; |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var array<int,array<int,string>> |
|
| 34 | - */ |
|
| 32 | + /** |
|
| 33 | + * @var array<int,array<int,string>> |
|
| 34 | + */ |
|
| 35 | 35 | private $tagAncestry = array(); |
| 36 | 36 | |
| 37 | 37 | protected function init() : void |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | return !$this->isInTagAttributes() && !$this->isInExcludedTag(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Retrieves the part of the subject string that comes |
|
| 48 | - * before the command. |
|
| 49 | - * |
|
| 50 | - * @return string |
|
| 51 | - */ |
|
| 46 | + /** |
|
| 47 | + * Retrieves the part of the subject string that comes |
|
| 48 | + * before the command. |
|
| 49 | + * |
|
| 50 | + * @return string |
|
| 51 | + */ |
|
| 52 | 52 | private function getHaystackBefore() : string |
| 53 | 53 | { |
| 54 | 54 | $pos = $this->getStartPosition(); |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | return $this->subject->getSubstr(0, $pos).self::COMMAND_MARKER.'>'; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Whether the command is nested in one of the tags |
|
| 70 | - * that have been added to the list of excluded tags. |
|
| 71 | - * |
|
| 72 | - * @return bool |
|
| 73 | - */ |
|
| 68 | + /** |
|
| 69 | + * Whether the command is nested in one of the tags |
|
| 70 | + * that have been added to the list of excluded tags. |
|
| 71 | + * |
|
| 72 | + * @return bool |
|
| 73 | + */ |
|
| 74 | 74 | protected function isInExcludedTag() : bool |
| 75 | 75 | { |
| 76 | 76 | $tagNames = $this->getParentTags(); |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | return false; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Retrieves a list of the command's parent HTML tags, from |
|
| 91 | - * highest to lowest. |
|
| 92 | - * |
|
| 93 | - * @return string[] |
|
| 94 | - */ |
|
| 89 | + /** |
|
| 90 | + * Retrieves a list of the command's parent HTML tags, from |
|
| 91 | + * highest to lowest. |
|
| 92 | + * |
|
| 93 | + * @return string[] |
|
| 94 | + */ |
|
| 95 | 95 | private function getParentTags() : array |
| 96 | 96 | { |
| 97 | 97 | $tags = $this->getTagAncestry(); |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | return $stack; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Checks whether the command is located within the attributes |
|
| 121 | - * of an HTML tag. |
|
| 122 | - * |
|
| 123 | - * @return bool |
|
| 124 | - */ |
|
| 119 | + /** |
|
| 120 | + * Checks whether the command is located within the attributes |
|
| 121 | + * of an HTML tag. |
|
| 122 | + * |
|
| 123 | + * @return bool |
|
| 124 | + */ |
|
| 125 | 125 | protected function isInTagAttributes() : bool |
| 126 | 126 | { |
| 127 | 127 | $tags = $this->getTagAncestry(); |
@@ -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 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | private function getTagAncestry() : array |
| 143 | 143 | { |
| 144 | - if($this->ancestryChecked) |
|
| 144 | + if ($this->ancestryChecked) |
|
| 145 | 145 | { |
| 146 | 146 | return $this->tagAncestry; |
| 147 | 147 | } |
@@ -119,8 +119,7 @@ |
||
| 119 | 119 | if($closing) |
| 120 | 120 | { |
| 121 | 121 | array_pop($stack); |
| 122 | - } |
|
| 123 | - else |
|
| 122 | + } else |
|
| 124 | 123 | { |
| 125 | 124 | $stack[] = $tagName; |
| 126 | 125 | } |
@@ -29,9 +29,9 @@ |
||
| 29 | 29 | |
| 30 | 30 | const ERROR_INVALID_TAG_TEMPLATE = 66101; |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 32 | + /** |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | 35 | private $tagTemplate = '<span class="mailcode-marked-variable">%s</span>'; |
| 36 | 36 | |
| 37 | 37 | protected function initFormatting() : void |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | |
| 41 | 41 | public function setTemplate(string $template) : void |
| 42 | 42 | { |
| 43 | - if(substr_count($template, '%s') !== 1) |
|
| 43 | + if (substr_count($template, '%s') !== 1) |
|
| 44 | 44 | { |
| 45 | 45 | throw new Mailcode_Exception( |
| 46 | 46 | 'Invalid tag template', |
@@ -25,11 +25,11 @@ |
||
| 25 | 25 | return PHP_INT_MAX; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Formats the specified string according to the formatter. |
|
| 30 | - * Retrieve the updated string from the string container used |
|
| 31 | - * to create the formatter, or use `getSubjectString()`. |
|
| 32 | - */ |
|
| 28 | + /** |
|
| 29 | + * Formats the specified string according to the formatter. |
|
| 30 | + * Retrieve the updated string from the string container used |
|
| 31 | + * to create the formatter, or use `getSubjectString()`. |
|
| 32 | + */ |
|
| 33 | 33 | public function format() : void |
| 34 | 34 | { |
| 35 | 35 | $locations = $this->resolveLocations(); |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | { |
| 35 | 35 | $locations = $this->resolveLocations(); |
| 36 | 36 | |
| 37 | - foreach($locations as $location) |
|
| 37 | + foreach ($locations as $location) |
|
| 38 | 38 | { |
| 39 | 39 | $location->format(); |
| 40 | 40 | |
@@ -32,24 +32,24 @@ discard block |
||
| 32 | 32 | const ERROR_TOO_MANY_REPLACERS = 65902; |
| 33 | 33 | const ERROR_NO_FORMATTERS_ADDED = 65903; |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var Mailcode_Parser_Safeguard |
|
| 37 | - */ |
|
| 35 | + /** |
|
| 36 | + * @var Mailcode_Parser_Safeguard |
|
| 37 | + */ |
|
| 38 | 38 | private $safeguard; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var Mailcode_Parser_Safeguard_Formatter[] |
|
| 42 | - */ |
|
| 40 | + /** |
|
| 41 | + * @var Mailcode_Parser_Safeguard_Formatter[] |
|
| 42 | + */ |
|
| 43 | 43 | private $formatters = array(); |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var Mailcode_StringContainer |
|
| 47 | - */ |
|
| 45 | + /** |
|
| 46 | + * @var Mailcode_StringContainer |
|
| 47 | + */ |
|
| 48 | 48 | private $subject; |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var boolean |
|
| 52 | - */ |
|
| 50 | + /** |
|
| 51 | + * @var boolean |
|
| 52 | + */ |
|
| 53 | 53 | private $applied = false; |
| 54 | 54 | |
| 55 | 55 | public function __construct(Mailcode_Parser_Safeguard $safeguard, Mailcode_StringContainer $subject) |
@@ -91,17 +91,17 @@ discard block |
||
| 91 | 91 | return $formatter; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Adds a formatter that will surround all variables with |
|
| 96 | - * markup to highlight them independently of command syntax |
|
| 97 | - * highlighting. |
|
| 98 | - * |
|
| 99 | - * This is used to mark variables visually even after commands |
|
| 100 | - * have been replaced by the target system's post processing. |
|
| 101 | - * Can be combined with a replacer and other formats. |
|
| 102 | - * |
|
| 103 | - * @return Mailcode_Parser_Safeguard_Formatter_Type_MarkVariables |
|
| 104 | - */ |
|
| 94 | + /** |
|
| 95 | + * Adds a formatter that will surround all variables with |
|
| 96 | + * markup to highlight them independently of command syntax |
|
| 97 | + * highlighting. |
|
| 98 | + * |
|
| 99 | + * This is used to mark variables visually even after commands |
|
| 100 | + * have been replaced by the target system's post processing. |
|
| 101 | + * Can be combined with a replacer and other formats. |
|
| 102 | + * |
|
| 103 | + * @return Mailcode_Parser_Safeguard_Formatter_Type_MarkVariables |
|
| 104 | + */ |
|
| 105 | 105 | public function formatWithMarkedVariables() : Mailcode_Parser_Safeguard_Formatter_Type_MarkVariables |
| 106 | 106 | { |
| 107 | 107 | $formatter = $this->createMarkVariables(); |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - /** |
|
| 199 | - * Counts the amount of replacer formatters that have been added. |
|
| 200 | - * |
|
| 201 | - * @return int |
|
| 202 | - */ |
|
| 198 | + /** |
|
| 199 | + * Counts the amount of replacer formatters that have been added. |
|
| 200 | + * |
|
| 201 | + * @return int |
|
| 202 | + */ |
|
| 203 | 203 | private function countReplacers() : int |
| 204 | 204 | { |
| 205 | 205 | $count = 0; |
@@ -215,37 +215,37 @@ discard block |
||
| 215 | 215 | return $count; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - /** |
|
| 219 | - * Creates a formatter that adds HTML syntax highlighting |
|
| 220 | - * for all commands in the specified string, intelligently |
|
| 221 | - * checking the location of the commands to ensure that they |
|
| 222 | - * can be syntax highlighted. |
|
| 223 | - * |
|
| 224 | - * For example, commands in HTML attributes will not be |
|
| 225 | - * highlighted, as this would break the HTML. |
|
| 226 | - * |
|
| 227 | - * @return Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting |
|
| 228 | - */ |
|
| 218 | + /** |
|
| 219 | + * Creates a formatter that adds HTML syntax highlighting |
|
| 220 | + * for all commands in the specified string, intelligently |
|
| 221 | + * checking the location of the commands to ensure that they |
|
| 222 | + * can be syntax highlighted. |
|
| 223 | + * |
|
| 224 | + * For example, commands in HTML attributes will not be |
|
| 225 | + * highlighted, as this would break the HTML. |
|
| 226 | + * |
|
| 227 | + * @return Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting |
|
| 228 | + */ |
|
| 229 | 229 | public function createHTMLHighlighting() : Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting |
| 230 | 230 | { |
| 231 | 231 | return new Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting($this); |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - /** |
|
| 235 | - * Creates the formatter that ensures that all commands |
|
| 236 | - * are placed on a separate line in the subject string. |
|
| 237 | - */ |
|
| 234 | + /** |
|
| 235 | + * Creates the formatter that ensures that all commands |
|
| 236 | + * are placed on a separate line in the subject string. |
|
| 237 | + */ |
|
| 238 | 238 | public function createSingleLines() : Mailcode_Parser_Safeguard_Formatter_Type_SingleLines |
| 239 | 239 | { |
| 240 | 240 | return new Mailcode_Parser_Safeguard_Formatter_Type_SingleLines($this); |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * Creates the formatter that replaces all commands by |
|
| 245 | - * their normalized variants. |
|
| 246 | - * |
|
| 247 | - * @return Mailcode_Parser_Safeguard_Formatter_Type_Normalized |
|
| 248 | - */ |
|
| 243 | + /** |
|
| 244 | + * Creates the formatter that replaces all commands by |
|
| 245 | + * their normalized variants. |
|
| 246 | + * |
|
| 247 | + * @return Mailcode_Parser_Safeguard_Formatter_Type_Normalized |
|
| 248 | + */ |
|
| 249 | 249 | public function createNormalized() : Mailcode_Parser_Safeguard_Formatter_Type_Normalized |
| 250 | 250 | { |
| 251 | 251 | return new Mailcode_Parser_Safeguard_Formatter_Type_Normalized($this); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | public function applyFormatting() : void |
| 133 | 133 | { |
| 134 | - if($this->applied) |
|
| 134 | + if ($this->applied) |
|
| 135 | 135 | { |
| 136 | 136 | return; |
| 137 | 137 | } |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | private function applyFormatTypes() : void |
| 148 | 148 | { |
| 149 | - foreach($this->formatters as $formatter) |
|
| 149 | + foreach ($this->formatters as $formatter) |
|
| 150 | 150 | { |
| 151 | - if($formatter instanceof Mailcode_Parser_Safeguard_Formatter_FormatType) |
|
| 151 | + if ($formatter instanceof Mailcode_Parser_Safeguard_Formatter_FormatType) |
|
| 152 | 152 | { |
| 153 | 153 | $formatter->format(); |
| 154 | 154 | } |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | private function applyReplaceTypes() : void |
| 159 | 159 | { |
| 160 | - foreach($this->formatters as $formatter) |
|
| 160 | + foreach ($this->formatters as $formatter) |
|
| 161 | 161 | { |
| 162 | - if($formatter instanceof Mailcode_Parser_Safeguard_Formatter_ReplacerType) |
|
| 162 | + if ($formatter instanceof Mailcode_Parser_Safeguard_Formatter_ReplacerType) |
|
| 163 | 163 | { |
| 164 | 164 | $formatter->replace(); |
| 165 | 165 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | private function validateFormatters() : void |
| 170 | 170 | { |
| 171 | - if(empty($this->formatters)) |
|
| 171 | + if (empty($this->formatters)) |
|
| 172 | 172 | { |
| 173 | 173 | throw new Mailcode_Exception( |
| 174 | 174 | 'No formatters selected', |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | $amount = $this->countReplacers(); |
| 181 | 181 | |
| 182 | - if($amount > 1) |
|
| 182 | + if ($amount > 1) |
|
| 183 | 183 | { |
| 184 | 184 | throw new Mailcode_Exception( |
| 185 | 185 | 'More than one replacer formatter selected', |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | // by default, at minimum the normalized formatter must be selected. |
| 192 | - if($amount === 0) |
|
| 192 | + if ($amount === 0) |
|
| 193 | 193 | { |
| 194 | 194 | $this->replaceWithNormalized(); |
| 195 | 195 | } |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | { |
| 205 | 205 | $count = 0; |
| 206 | 206 | |
| 207 | - foreach($this->formatters as $formatter) |
|
| 207 | + foreach ($this->formatters as $formatter) |
|
| 208 | 208 | { |
| 209 | - if($formatter instanceof Mailcode_Parser_Safeguard_Formatter_ReplacerType) |
|
| 209 | + if ($formatter instanceof Mailcode_Parser_Safeguard_Formatter_ReplacerType) |
|
| 210 | 210 | { |
| 211 | 211 | $count++; |
| 212 | 212 | } |
@@ -53,50 +53,50 @@ discard block |
||
| 53 | 53 | const ERROR_EMPTY_DELIMITER = 47803; |
| 54 | 54 | const ERROR_PLACEHOLDER_NOT_FOUND = 47804; |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var Mailcode_Parser |
|
| 58 | - */ |
|
| 56 | + /** |
|
| 57 | + * @var Mailcode_Parser |
|
| 58 | + */ |
|
| 59 | 59 | protected $parser; |
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @var Mailcode_Collection |
|
| 63 | - */ |
|
| 61 | + /** |
|
| 62 | + * @var Mailcode_Collection |
|
| 63 | + */ |
|
| 64 | 64 | protected $commands; |
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * @var string |
|
| 68 | - */ |
|
| 66 | + /** |
|
| 67 | + * @var string |
|
| 68 | + */ |
|
| 69 | 69 | protected $originalString; |
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @var Mailcode_Collection |
|
| 73 | - */ |
|
| 71 | + /** |
|
| 72 | + * @var Mailcode_Collection |
|
| 73 | + */ |
|
| 74 | 74 | protected $collection; |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Counter for the placeholders, global for all placeholders. |
|
| 78 | - * @var integer |
|
| 79 | - */ |
|
| 76 | + /** |
|
| 77 | + * Counter for the placeholders, global for all placeholders. |
|
| 78 | + * @var integer |
|
| 79 | + */ |
|
| 80 | 80 | private static $counter = 0; |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @var Mailcode_Parser_Safeguard_Placeholder[] |
|
| 84 | - */ |
|
| 82 | + /** |
|
| 83 | + * @var Mailcode_Parser_Safeguard_Placeholder[] |
|
| 84 | + */ |
|
| 85 | 85 | protected $placeholders; |
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * @var string |
|
| 89 | - */ |
|
| 87 | + /** |
|
| 88 | + * @var string |
|
| 89 | + */ |
|
| 90 | 90 | protected $delimiter = '__'; |
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * @var string[]|NULL |
|
| 94 | - */ |
|
| 92 | + /** |
|
| 93 | + * @var string[]|NULL |
|
| 94 | + */ |
|
| 95 | 95 | protected $placeholderStrings; |
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * @var Mailcode_Parser_Safeguard_Formatting|NULL |
|
| 99 | - */ |
|
| 97 | + /** |
|
| 98 | + * @var Mailcode_Parser_Safeguard_Formatting|NULL |
|
| 99 | + */ |
|
| 100 | 100 | private $formatting = null; |
| 101 | 101 | |
| 102 | 102 | public function __construct(Mailcode_Parser $parser, string $subject) |
@@ -105,25 +105,25 @@ discard block |
||
| 105 | 105 | $this->originalString = $subject; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Retrieves the string the safeguard was created for. |
|
| 110 | - * |
|
| 111 | - * @return string |
|
| 112 | - */ |
|
| 108 | + /** |
|
| 109 | + * Retrieves the string the safeguard was created for. |
|
| 110 | + * |
|
| 111 | + * @return string |
|
| 112 | + */ |
|
| 113 | 113 | public function getOriginalString() : string |
| 114 | 114 | { |
| 115 | 115 | return $this->originalString; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Sets the delimiter character sequence used to prepend |
|
| 120 | - * and append to the placeholders. |
|
| 121 | - * |
|
| 122 | - * The delimiter's default is "__" (two underscores). |
|
| 123 | - * |
|
| 124 | - * @param string $delimiter |
|
| 125 | - * @return Mailcode_Parser_Safeguard |
|
| 126 | - */ |
|
| 118 | + /** |
|
| 119 | + * Sets the delimiter character sequence used to prepend |
|
| 120 | + * and append to the placeholders. |
|
| 121 | + * |
|
| 122 | + * The delimiter's default is "__" (two underscores). |
|
| 123 | + * |
|
| 124 | + * @param string $delimiter |
|
| 125 | + * @return Mailcode_Parser_Safeguard |
|
| 126 | + */ |
|
| 127 | 127 | public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard |
| 128 | 128 | { |
| 129 | 129 | if(empty($delimiter)) |
@@ -145,15 +145,15 @@ discard block |
||
| 145 | 145 | return $this->delimiter; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Retrieves the safe string in which all commands have been replaced |
|
| 150 | - * by placeholder strings. |
|
| 151 | - * |
|
| 152 | - * @return string |
|
| 153 | - * @throws Mailcode_Exception |
|
| 154 | - * |
|
| 155 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 156 | - */ |
|
| 148 | + /** |
|
| 149 | + * Retrieves the safe string in which all commands have been replaced |
|
| 150 | + * by placeholder strings. |
|
| 151 | + * |
|
| 152 | + * @return string |
|
| 153 | + * @throws Mailcode_Exception |
|
| 154 | + * |
|
| 155 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 156 | + */ |
|
| 157 | 157 | public function makeSafe() : string |
| 158 | 158 | { |
| 159 | 159 | $this->requireValidCollection(); |
@@ -161,16 +161,16 @@ discard block |
||
| 161 | 161 | return $this->makeSafePartial(); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * Like makeSafe(), but allows partial (invalid) commands: use this |
|
| 166 | - * if the subject string may contain only part of the whole set of |
|
| 167 | - * commands. |
|
| 168 | - * |
|
| 169 | - * Example: parsing a text with an opening if statement, without the |
|
| 170 | - * matching end statement. |
|
| 171 | - * |
|
| 172 | - * @return string |
|
| 173 | - */ |
|
| 164 | + /** |
|
| 165 | + * Like makeSafe(), but allows partial (invalid) commands: use this |
|
| 166 | + * if the subject string may contain only part of the whole set of |
|
| 167 | + * commands. |
|
| 168 | + * |
|
| 169 | + * Example: parsing a text with an opening if statement, without the |
|
| 170 | + * matching end statement. |
|
| 171 | + * |
|
| 172 | + * @return string |
|
| 173 | + */ |
|
| 174 | 174 | public function makeSafePartial() : string |
| 175 | 175 | { |
| 176 | 176 | $placeholders = $this->getPlaceholders(); |
@@ -200,13 +200,13 @@ discard block |
||
| 200 | 200 | return $string; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - /** |
|
| 204 | - * Creates a formatting handler, which can be used to specify |
|
| 205 | - * which formattings to use for the commands in the subject string. |
|
| 206 | - * |
|
| 207 | - * @param Mailcode_StringContainer|string $subject |
|
| 208 | - * @return Mailcode_Parser_Safeguard_Formatting |
|
| 209 | - */ |
|
| 203 | + /** |
|
| 204 | + * Creates a formatting handler, which can be used to specify |
|
| 205 | + * which formattings to use for the commands in the subject string. |
|
| 206 | + * |
|
| 207 | + * @param Mailcode_StringContainer|string $subject |
|
| 208 | + * @return Mailcode_Parser_Safeguard_Formatting |
|
| 209 | + */ |
|
| 210 | 210 | public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting |
| 211 | 211 | { |
| 212 | 212 | if(is_string($subject)) |
@@ -217,12 +217,12 @@ discard block |
||
| 217 | 217 | return new Mailcode_Parser_Safeguard_Formatting($this, $subject); |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - /** |
|
| 221 | - * Retrieves all placeholders that have to be added to |
|
| 222 | - * the subject text. |
|
| 223 | - * |
|
| 224 | - * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[] |
|
| 225 | - */ |
|
| 220 | + /** |
|
| 221 | + * Retrieves all placeholders that have to be added to |
|
| 222 | + * the subject text. |
|
| 223 | + * |
|
| 224 | + * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[] |
|
| 225 | + */ |
|
| 226 | 226 | public function getPlaceholders() |
| 227 | 227 | { |
| 228 | 228 | if(isset($this->placeholders)) |
@@ -269,16 +269,16 @@ discard block |
||
| 269 | 269 | return $formatting->toString(); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - /** |
|
| 273 | - * Makes the string whole again after transforming or filtering it, |
|
| 274 | - * by replacing the command placeholders with the original commands. |
|
| 275 | - * |
|
| 276 | - * @param string $string |
|
| 277 | - * @return string |
|
| 278 | - * @throws Mailcode_Exception |
|
| 279 | - * |
|
| 280 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 281 | - */ |
|
| 272 | + /** |
|
| 273 | + * Makes the string whole again after transforming or filtering it, |
|
| 274 | + * by replacing the command placeholders with the original commands. |
|
| 275 | + * |
|
| 276 | + * @param string $string |
|
| 277 | + * @return string |
|
| 278 | + * @throws Mailcode_Exception |
|
| 279 | + * |
|
| 280 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 281 | + */ |
|
| 282 | 282 | public function makeWhole(string $string) : string |
| 283 | 283 | { |
| 284 | 284 | return $this->restore( |
@@ -288,15 +288,15 @@ discard block |
||
| 288 | 288 | ); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - /** |
|
| 292 | - * Like `makeWhole()`, but ignores missing command placeholders. |
|
| 293 | - * |
|
| 294 | - * @param string $string |
|
| 295 | - * @return string |
|
| 296 | - * @throws Mailcode_Exception |
|
| 297 | - * |
|
| 298 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 299 | - */ |
|
| 291 | + /** |
|
| 292 | + * Like `makeWhole()`, but ignores missing command placeholders. |
|
| 293 | + * |
|
| 294 | + * @param string $string |
|
| 295 | + * @return string |
|
| 296 | + * @throws Mailcode_Exception |
|
| 297 | + * |
|
| 298 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 299 | + */ |
|
| 300 | 300 | public function makeWholePartial(string $string) : string |
| 301 | 301 | { |
| 302 | 302 | return $this->restore( |
@@ -306,19 +306,19 @@ discard block |
||
| 306 | 306 | ); |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - /** |
|
| 310 | - * Like `makeWhole()`, but replaces the commands with a syntax |
|
| 311 | - * highlighted version, meant for human readable texts only. |
|
| 312 | - * |
|
| 313 | - * Note: the commands lose their functionality (They cannot be |
|
| 314 | - * parsed from that string again). |
|
| 315 | - * |
|
| 316 | - * @param string $string |
|
| 317 | - * @return string |
|
| 318 | - * @throws Mailcode_Exception |
|
| 319 | - * |
|
| 320 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 321 | - */ |
|
| 309 | + /** |
|
| 310 | + * Like `makeWhole()`, but replaces the commands with a syntax |
|
| 311 | + * highlighted version, meant for human readable texts only. |
|
| 312 | + * |
|
| 313 | + * Note: the commands lose their functionality (They cannot be |
|
| 314 | + * parsed from that string again). |
|
| 315 | + * |
|
| 316 | + * @param string $string |
|
| 317 | + * @return string |
|
| 318 | + * @throws Mailcode_Exception |
|
| 319 | + * |
|
| 320 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 321 | + */ |
|
| 322 | 322 | public function makeHighlighted(string $string) : string |
| 323 | 323 | { |
| 324 | 324 | return $this->restore( |
@@ -328,15 +328,15 @@ discard block |
||
| 328 | 328 | ); |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - /** |
|
| 332 | - * Like `makeHighlighted()`, but ignores missing command placeholders. |
|
| 333 | - * |
|
| 334 | - * @param string $string |
|
| 335 | - * @return string |
|
| 336 | - * @throws Mailcode_Exception |
|
| 337 | - * |
|
| 338 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 339 | - */ |
|
| 331 | + /** |
|
| 332 | + * Like `makeHighlighted()`, but ignores missing command placeholders. |
|
| 333 | + * |
|
| 334 | + * @param string $string |
|
| 335 | + * @return string |
|
| 336 | + * @throws Mailcode_Exception |
|
| 337 | + * |
|
| 338 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 339 | + */ |
|
| 340 | 340 | public function makeHighlightedPartial(string $string) : string |
| 341 | 341 | { |
| 342 | 342 | return $this->restore( |
@@ -346,11 +346,11 @@ discard block |
||
| 346 | 346 | ); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - /** |
|
| 350 | - * Retrieves the commands collection contained in the string. |
|
| 351 | - * |
|
| 352 | - * @return Mailcode_Collection |
|
| 353 | - */ |
|
| 349 | + /** |
|
| 350 | + * Retrieves the commands collection contained in the string. |
|
| 351 | + * |
|
| 352 | + * @return Mailcode_Collection |
|
| 353 | + */ |
|
| 354 | 354 | public function getCollection() : Mailcode_Collection |
| 355 | 355 | { |
| 356 | 356 | if(isset($this->collection)) |
@@ -368,11 +368,11 @@ discard block |
||
| 368 | 368 | return $this->getCollection()->isValid(); |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - /** |
|
| 372 | - * @throws Mailcode_Exception |
|
| 373 | - * |
|
| 374 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 375 | - */ |
|
| 371 | + /** |
|
| 372 | + * @throws Mailcode_Exception |
|
| 373 | + * |
|
| 374 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 375 | + */ |
|
| 376 | 376 | protected function requireValidCollection() : void |
| 377 | 377 | { |
| 378 | 378 | if($this->getCollection()->isValid()) |
@@ -391,11 +391,11 @@ discard block |
||
| 391 | 391 | ); |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - /** |
|
| 395 | - * Retrieves a list of all placeholder IDs used in the text. |
|
| 396 | - * |
|
| 397 | - * @return string[] |
|
| 398 | - */ |
|
| 394 | + /** |
|
| 395 | + * Retrieves a list of all placeholder IDs used in the text. |
|
| 396 | + * |
|
| 397 | + * @return string[] |
|
| 398 | + */ |
|
| 399 | 399 | public function getPlaceholderStrings() : array |
| 400 | 400 | { |
| 401 | 401 | if(is_array($this->placeholderStrings)) |
@@ -422,13 +422,13 @@ discard block |
||
| 422 | 422 | return in_array($subject, $ids); |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - /** |
|
| 426 | - * Retrieves a placeholder instance by its ID. |
|
| 427 | - * |
|
| 428 | - * @param int $id |
|
| 429 | - * @throws Mailcode_Exception If the placeholder was not found. |
|
| 430 | - * @return Mailcode_Parser_Safeguard_Placeholder |
|
| 431 | - */ |
|
| 425 | + /** |
|
| 426 | + * Retrieves a placeholder instance by its ID. |
|
| 427 | + * |
|
| 428 | + * @param int $id |
|
| 429 | + * @throws Mailcode_Exception If the placeholder was not found. |
|
| 430 | + * @return Mailcode_Parser_Safeguard_Placeholder |
|
| 431 | + */ |
|
| 432 | 432 | public function getPlaceholderByID(int $id) : Mailcode_Parser_Safeguard_Placeholder |
| 433 | 433 | { |
| 434 | 434 | $placeholders = $this->getPlaceholders(); |
@@ -451,13 +451,13 @@ discard block |
||
| 451 | 451 | ); |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - /** |
|
| 455 | - * Retrieves a placeholder instance by its replacement text. |
|
| 456 | - * |
|
| 457 | - * @param string $string |
|
| 458 | - * @throws Mailcode_Exception |
|
| 459 | - * @return Mailcode_Parser_Safeguard_Placeholder |
|
| 460 | - */ |
|
| 454 | + /** |
|
| 455 | + * Retrieves a placeholder instance by its replacement text. |
|
| 456 | + * |
|
| 457 | + * @param string $string |
|
| 458 | + * @throws Mailcode_Exception |
|
| 459 | + * @return Mailcode_Parser_Safeguard_Placeholder |
|
| 460 | + */ |
|
| 461 | 461 | public function getPlaceholderByString(string $string) : Mailcode_Parser_Safeguard_Placeholder |
| 462 | 462 | { |
| 463 | 463 | $placeholders = $this->getPlaceholders(); |
@@ -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,16 +248,16 @@ 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($highlighted) |
|
| 260 | + if ($highlighted) |
|
| 261 | 261 | { |
| 262 | 262 | $formatting->replaceWithHTMLHighlighting(); |
| 263 | 263 | } |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | */ |
| 354 | 354 | public function getCollection() : Mailcode_Collection |
| 355 | 355 | { |
| 356 | - if(isset($this->collection)) |
|
| 356 | + if (isset($this->collection)) |
|
| 357 | 357 | { |
| 358 | 358 | return $this->collection; |
| 359 | 359 | } |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | protected function requireValidCollection() : void |
| 377 | 377 | { |
| 378 | - if($this->getCollection()->isValid()) |
|
| 378 | + if ($this->getCollection()->isValid()) |
|
| 379 | 379 | { |
| 380 | 380 | return; |
| 381 | 381 | } |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | public function getPlaceholderStrings() : array |
| 400 | 400 | { |
| 401 | - if(is_array($this->placeholderStrings)) |
|
| 401 | + if (is_array($this->placeholderStrings)) |
|
| 402 | 402 | { |
| 403 | 403 | return $this->placeholderStrings; |
| 404 | 404 | } |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | |
| 408 | 408 | $this->placeholderStrings = array(); |
| 409 | 409 | |
| 410 | - foreach($placeholders as $placeholder) |
|
| 410 | + foreach ($placeholders as $placeholder) |
|
| 411 | 411 | { |
| 412 | 412 | $this->placeholderStrings[] = $placeholder->getReplacementText(); |
| 413 | 413 | } |
@@ -433,9 +433,9 @@ discard block |
||
| 433 | 433 | { |
| 434 | 434 | $placeholders = $this->getPlaceholders(); |
| 435 | 435 | |
| 436 | - foreach($placeholders as $placeholder) |
|
| 436 | + foreach ($placeholders as $placeholder) |
|
| 437 | 437 | { |
| 438 | - if($placeholder->getID() === $id) |
|
| 438 | + if ($placeholder->getID() === $id) |
|
| 439 | 439 | { |
| 440 | 440 | return $placeholder; |
| 441 | 441 | } |
@@ -462,9 +462,9 @@ discard block |
||
| 462 | 462 | { |
| 463 | 463 | $placeholders = $this->getPlaceholders(); |
| 464 | 464 | |
| 465 | - foreach($placeholders as $placeholder) |
|
| 465 | + foreach ($placeholders as $placeholder) |
|
| 466 | 466 | { |
| 467 | - if($placeholder->getReplacementText() === $string) |
|
| 467 | + if ($placeholder->getReplacementText() === $string) |
|
| 468 | 468 | { |
| 469 | 469 | return $placeholder; |
| 470 | 470 | } |
@@ -260,8 +260,7 @@ |
||
| 260 | 260 | if($highlighted) |
| 261 | 261 | { |
| 262 | 262 | $formatting->replaceWithHTMLHighlighting(); |
| 263 | - } |
|
| 264 | - else |
|
| 263 | + } else |
|
| 265 | 264 | { |
| 266 | 265 | $formatting->replaceWithNormalized(); |
| 267 | 266 | } |