@@ -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,12 +67,12 @@ 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 | } |
| 74 | 74 | |
| 75 | - if($this->isWithinCommand($prevPos)) |
|
| 75 | + if ($this->isWithinCommand($prevPos)) |
|
| 76 | 76 | { |
| 77 | 77 | $this->log(sprintf( |
| 78 | 78 | 'Prepend: NO | Position: [%s] | Is within a mailcode command.', |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $prev = $this->subject->getSubstr($prevPos, $this->eolLength); |
| 86 | 86 | |
| 87 | - if($prev !== $this->formatter->getEOLChar()) |
|
| 87 | + if ($prev !== $this->formatter->getEOLChar()) |
|
| 88 | 88 | { |
| 89 | 89 | $this->log(sprintf( |
| 90 | 90 | 'Prepend: YES | Position: [%s] | Characters: [%s] | Do not match the EOL character.', |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $position = $this->getEndPosition(); |
| 104 | 104 | |
| 105 | 105 | // we're at the end of the string |
| 106 | - if($position === false || $position >= $subjectLength) |
|
| 106 | + if ($position === false || $position >= $subjectLength) |
|
| 107 | 107 | { |
| 108 | 108 | $this->log(sprintf( |
| 109 | 109 | 'Append: NO | Position: [%s] | End of string, or too long | Subject length: [%s]', |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $nextPos = $position + $this->eolLength; |
| 118 | 118 | |
| 119 | - if($nextPos > $subjectLength) |
|
| 119 | + if ($nextPos > $subjectLength) |
|
| 120 | 120 | { |
| 121 | 121 | $nextPos = $subjectLength - $this->eolLength; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if($this->isWithinCommand($nextPos)) |
|
| 124 | + if ($this->isWithinCommand($nextPos)) |
|
| 125 | 125 | { |
| 126 | 126 | $this->log(sprintf( |
| 127 | 127 | 'Append: YES | Position: [%s] | Is within a mailcode command.', |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | $next = $this->subject->getSubstr($nextPos, $this->eolLength); |
| 137 | 137 | |
| 138 | - if($next !== $this->formatter->getEOLChar()) |
|
| 138 | + if ($next !== $this->formatter->getEOLChar()) |
|
| 139 | 139 | { |
| 140 | 140 | $this->log(sprintf( |
| 141 | 141 | 'Append: YES | Position: [%s] | Next characters: [%s] | Do not match the EOL character.', |
@@ -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 | |
@@ -24,34 +24,34 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | const ERROR_PLACEHOLDER_NOT_FOUND = 66001; |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var Mailcode_Parser_Safeguard_Formatter |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * @var Mailcode_Parser_Safeguard_Formatter |
|
| 29 | + */ |
|
| 30 | 30 | protected $formatter; |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 32 | + /** |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | 35 | protected $append = ''; |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 37 | + /** |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | 40 | protected $prepend = ''; |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var Mailcode_Parser_Safeguard_Placeholder |
|
| 44 | - */ |
|
| 42 | + /** |
|
| 43 | + * @var Mailcode_Parser_Safeguard_Placeholder |
|
| 44 | + */ |
|
| 45 | 45 | protected $placeholder; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var Mailcode_StringContainer |
|
| 49 | - */ |
|
| 47 | + /** |
|
| 48 | + * @var Mailcode_StringContainer |
|
| 49 | + */ |
|
| 50 | 50 | protected $subject; |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @var string[] |
|
| 54 | - */ |
|
| 52 | + /** |
|
| 53 | + * @var string[] |
|
| 54 | + */ |
|
| 55 | 55 | protected $log = array(); |
| 56 | 56 | |
| 57 | 57 | public function __construct(Mailcode_Parser_Safeguard_Formatter $formatter, Mailcode_Parser_Safeguard_Placeholder $placeholder) |
@@ -67,22 +67,22 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | abstract public function requiresAdjustment() : bool; |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * @return int|boolean |
|
| 72 | - */ |
|
| 70 | + /** |
|
| 71 | + * @return int|boolean |
|
| 72 | + */ |
|
| 73 | 73 | public function getStartPosition() |
| 74 | 74 | { |
| 75 | 75 | return $this->subject->getSubstrPosition($this->placeholder->getReplacementText()); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Checks whether the specified position within the string |
|
| 80 | - * is within another command's placeholder (excluding this |
|
| 81 | - * location's placeholder). |
|
| 82 | - * |
|
| 83 | - * @param int $position |
|
| 84 | - * @return bool |
|
| 85 | - */ |
|
| 78 | + /** |
|
| 79 | + * Checks whether the specified position within the string |
|
| 80 | + * is within another command's placeholder (excluding this |
|
| 81 | + * location's placeholder). |
|
| 82 | + * |
|
| 83 | + * @param int $position |
|
| 84 | + * @return bool |
|
| 85 | + */ |
|
| 86 | 86 | public function isWithinCommand(int $position) : bool |
| 87 | 87 | { |
| 88 | 88 | $placeholders = $this->formatter->getSafeguard()->getPlaceholders(); |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | return false; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * @return int|boolean |
|
| 119 | - */ |
|
| 117 | + /** |
|
| 118 | + * @return int|boolean |
|
| 119 | + */ |
|
| 120 | 120 | public function getEndPosition() |
| 121 | 121 | { |
| 122 | 122 | $start = $this->getStartPosition(); |
@@ -139,14 +139,14 @@ discard block |
||
| 139 | 139 | return $this->placeholder; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Replaces the placeholder with the specified replacement text. |
|
| 144 | - * |
|
| 145 | - * @param string $replacementText |
|
| 146 | - * @throws Mailcode_Exception |
|
| 147 | - * |
|
| 148 | - * @see Mailcode_Parser_Safeguard_Formatter_Location::ERROR_PLACEHOLDER_NOT_FOUND |
|
| 149 | - */ |
|
| 142 | + /** |
|
| 143 | + * Replaces the placeholder with the specified replacement text. |
|
| 144 | + * |
|
| 145 | + * @param string $replacementText |
|
| 146 | + * @throws Mailcode_Exception |
|
| 147 | + * |
|
| 148 | + * @see Mailcode_Parser_Safeguard_Formatter_Location::ERROR_PLACEHOLDER_NOT_FOUND |
|
| 149 | + */ |
|
| 150 | 150 | public function replaceWith(string $replacementText) : void |
| 151 | 151 | { |
| 152 | 152 | $needle = $this->placeholder->getReplacementText(); |
@@ -189,10 +189,10 @@ discard block |
||
| 189 | 189 | ); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * Retrieves the location's log messages, if any. |
|
| 194 | - * @return string[] |
|
| 195 | - */ |
|
| 192 | + /** |
|
| 193 | + * Retrieves the location's log messages, if any. |
|
| 194 | + * @return string[] |
|
| 195 | + */ |
|
| 196 | 196 | public function getLog() : array |
| 197 | 197 | { |
| 198 | 198 | return $this->log; |
@@ -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 | } |
@@ -27,19 +27,19 @@ discard block |
||
| 27 | 27 | { |
| 28 | 28 | const ERROR_INVALID_LOCATION_INSTANCE = 65601; |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var Mailcode_Parser_Safeguard_Formatting |
|
| 32 | - */ |
|
| 30 | + /** |
|
| 31 | + * @var Mailcode_Parser_Safeguard_Formatting |
|
| 32 | + */ |
|
| 33 | 33 | protected $formatting; |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var Mailcode_StringContainer |
|
| 37 | - */ |
|
| 35 | + /** |
|
| 36 | + * @var Mailcode_StringContainer |
|
| 37 | + */ |
|
| 38 | 38 | protected $subject; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var string[] |
|
| 42 | - */ |
|
| 40 | + /** |
|
| 41 | + * @var string[] |
|
| 42 | + */ |
|
| 43 | 43 | protected $log = array(); |
| 44 | 44 | |
| 45 | 45 | public function __construct(Mailcode_Parser_Safeguard_Formatting $formatting) |
@@ -93,12 +93,12 @@ discard block |
||
| 93 | 93 | ); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Retrieves all formatter-specific placeholder locations |
|
| 98 | - * in the subject string. |
|
| 99 | - * |
|
| 100 | - * @return Mailcode_Parser_Safeguard_Formatter_Location[] |
|
| 101 | - */ |
|
| 96 | + /** |
|
| 97 | + * Retrieves all formatter-specific placeholder locations |
|
| 98 | + * in the subject string. |
|
| 99 | + * |
|
| 100 | + * @return Mailcode_Parser_Safeguard_Formatter_Location[] |
|
| 101 | + */ |
|
| 102 | 102 | protected function resolveLocations() : array |
| 103 | 103 | { |
| 104 | 104 | $placeholders = $this->formatting->getSafeguard()->getPlaceholders(); |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | return $result; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Resolves the newline character used in the string. |
|
| 118 | - * |
|
| 119 | - * @param string $subject |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 116 | + /** |
|
| 117 | + * Resolves the newline character used in the string. |
|
| 118 | + * |
|
| 119 | + * @param string $subject |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | 122 | protected function resolveNewlineChar(string $subject) : string |
| 123 | 123 | { |
| 124 | 124 | $eol = ConvertHelper::detectEOLCharacter($subject); |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | ); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * @return string[] |
|
| 155 | - */ |
|
| 153 | + /** |
|
| 154 | + * @return string[] |
|
| 155 | + */ |
|
| 156 | 156 | public function getLog() : array |
| 157 | 157 | { |
| 158 | 158 | return $this->log; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | $instance = new $class($this, $placeholder); |
| 79 | 79 | |
| 80 | - if($instance instanceof Mailcode_Parser_Safeguard_Formatter_Location) |
|
| 80 | + if ($instance instanceof Mailcode_Parser_Safeguard_Formatter_Location) |
|
| 81 | 81 | { |
| 82 | 82 | return $instance; |
| 83 | 83 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | $result = array(); |
| 107 | 107 | |
| 108 | - foreach($placeholders as $placeholder) |
|
| 108 | + foreach ($placeholders as $placeholder) |
|
| 109 | 109 | { |
| 110 | 110 | $result[] = $this->createLocation($placeholder); |
| 111 | 111 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | { |
| 124 | 124 | $eol = ConvertHelper::detectEOLCharacter($subject); |
| 125 | 125 | |
| 126 | - if($eol) |
|
| 126 | + if ($eol) |
|
| 127 | 127 | { |
| 128 | 128 | $this->log(sprintf( |
| 129 | 129 | 'Detected EOL character: %s.', |
@@ -23,21 +23,21 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | trait Mailcode_Traits_Formatting_HTMLHighlighting |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * @var string[] |
|
| 28 | - */ |
|
| 26 | + /** |
|
| 27 | + * @var string[] |
|
| 28 | + */ |
|
| 29 | 29 | private $excludeTags = array( |
| 30 | 30 | 'style', // NOTE: style tags are excluded natively on the parser level. |
| 31 | 31 | 'script' |
| 32 | 32 | ); |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Adds an HTML tag name to the list of tags within which |
|
| 36 | - * commands may not be highlighted. |
|
| 37 | - * |
|
| 38 | - * @param string $tagName Case insensitive. |
|
| 39 | - * @return $this |
|
| 40 | - */ |
|
| 34 | + /** |
|
| 35 | + * Adds an HTML tag name to the list of tags within which |
|
| 36 | + * commands may not be highlighted. |
|
| 37 | + * |
|
| 38 | + * @param string $tagName Case insensitive. |
|
| 39 | + * @return $this |
|
| 40 | + */ |
|
| 41 | 41 | public function excludeTag(string $tagName) : Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting |
| 42 | 42 | { |
| 43 | 43 | $tagName = strtolower($tagName); |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | return $this; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Adds several exluded tag names at once. |
|
| 55 | - * |
|
| 56 | - * @param string[] $tagNames |
|
| 57 | - * @return $this |
|
| 58 | - */ |
|
| 53 | + /** |
|
| 54 | + * Adds several exluded tag names at once. |
|
| 55 | + * |
|
| 56 | + * @param string[] $tagNames |
|
| 57 | + * @return $this |
|
| 58 | + */ |
|
| 59 | 59 | public function excludeTags(array $tagNames) : Mailcode_Parser_Safeguard_Formatter_Type_HTMLHighlighting |
| 60 | 60 | { |
| 61 | 61 | foreach($tagNames as $tagName) |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | return $this; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Whether the specified tag name is in the exlusion list. |
|
| 71 | - * |
|
| 72 | - * @param string $tagName |
|
| 73 | - * @return bool |
|
| 74 | - */ |
|
| 69 | + /** |
|
| 70 | + * Whether the specified tag name is in the exlusion list. |
|
| 71 | + * |
|
| 72 | + * @param string $tagName |
|
| 73 | + * @return bool |
|
| 74 | + */ |
|
| 75 | 75 | public function isTagExcluded(string $tagName) : bool |
| 76 | 76 | { |
| 77 | 77 | $tagName = strtolower($tagName); |