| @@ -26,41 +26,41 @@ discard block | ||
| 26 | 26 | */ | 
| 27 | 27 | class Mailcode | 
| 28 | 28 |  { | 
| 29 | - /** | |
| 30 | - * @var Mailcode_Parser|NULL | |
| 31 | - */ | |
| 29 | + /** | |
| 30 | + * @var Mailcode_Parser|NULL | |
| 31 | + */ | |
| 32 | 32 | protected $parser = null; | 
| 33 | 33 | |
| 34 | - /** | |
| 35 | - * @var Mailcode_Commands|NULL | |
| 36 | - */ | |
| 34 | + /** | |
| 35 | + * @var Mailcode_Commands|NULL | |
| 36 | + */ | |
| 37 | 37 | protected $commands = null; | 
| 38 | 38 | |
| 39 | - /** | |
| 40 | - * @var Mailcode_Variables|NULL | |
| 41 | - */ | |
| 39 | + /** | |
| 40 | + * @var Mailcode_Variables|NULL | |
| 41 | + */ | |
| 42 | 42 | protected $variables = null; | 
| 43 | 43 | |
| 44 | - /** | |
| 45 | - * @var Mailcode_Translator|NULL | |
| 46 | - */ | |
| 44 | + /** | |
| 45 | + * @var Mailcode_Translator|NULL | |
| 46 | + */ | |
| 47 | 47 | protected $translator = null; | 
| 48 | 48 | |
| 49 | - /** | |
| 50 | - * Creates a new mailcode instance. | |
| 51 | - * @return Mailcode | |
| 52 | - */ | |
| 49 | + /** | |
| 50 | + * Creates a new mailcode instance. | |
| 51 | + * @return Mailcode | |
| 52 | + */ | |
| 53 | 53 | public static function create() : Mailcode | 
| 54 | 54 |      { | 
| 55 | 55 | return new Mailcode(); | 
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | - /** | |
| 59 | - * Parses the string to detect all commands contained within. | |
| 60 | - * | |
| 61 | - * @param string $string | |
| 62 | - * @return Mailcode_Collection | |
| 63 | - */ | |
| 58 | + /** | |
| 59 | + * Parses the string to detect all commands contained within. | |
| 60 | + * | |
| 61 | + * @param string $string | |
| 62 | + * @return Mailcode_Collection | |
| 63 | + */ | |
| 64 | 64 | public function parseString(string $string) : Mailcode_Collection | 
| 65 | 65 |      { | 
| 66 | 66 | return $this->getParser() | 
| @@ -68,11 +68,11 @@ discard block | ||
| 68 | 68 | ->getCollection(); | 
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | - /** | |
| 72 | - * Retrieves the string parser instance used to detect commands. | |
| 73 | - * | |
| 74 | - * @return Mailcode_Parser | |
| 75 | - */ | |
| 71 | + /** | |
| 72 | + * Retrieves the string parser instance used to detect commands. | |
| 73 | + * | |
| 74 | + * @return Mailcode_Parser | |
| 75 | + */ | |
| 76 | 76 | public function getParser() : Mailcode_Parser | 
| 77 | 77 |      { | 
| 78 | 78 | if(!isset($this->parser)) | 
| @@ -83,12 +83,12 @@ discard block | ||
| 83 | 83 | return $this->parser; | 
| 84 | 84 | } | 
| 85 | 85 | |
| 86 | - /** | |
| 87 | - * Retrieves the commands collection, which is used to | |
| 88 | - * access information on the available commands. | |
| 89 | - * | |
| 90 | - * @return Mailcode_Commands | |
| 91 | - */ | |
| 86 | + /** | |
| 87 | + * Retrieves the commands collection, which is used to | |
| 88 | + * access information on the available commands. | |
| 89 | + * | |
| 90 | + * @return Mailcode_Commands | |
| 91 | + */ | |
| 92 | 92 | public function getCommands() : Mailcode_Commands | 
| 93 | 93 |      { | 
| 94 | 94 | if(!isset($this->commands)) | 
| @@ -131,12 +131,12 @@ discard block | ||
| 131 | 131 | return $this->variables; | 
| 132 | 132 | } | 
| 133 | 133 | |
| 134 | - /** | |
| 135 | - * Creates the translator, which can be used to convert commands | |
| 136 | - * to another supported syntax. | |
| 137 | - * | |
| 138 | - * @return Mailcode_Translator | |
| 139 | - */ | |
| 134 | + /** | |
| 135 | + * Creates the translator, which can be used to convert commands | |
| 136 | + * to another supported syntax. | |
| 137 | + * | |
| 138 | + * @return Mailcode_Translator | |
| 139 | + */ | |
| 140 | 140 | public function createTranslator() : Mailcode_Translator | 
| 141 | 141 |      { | 
| 142 | 142 | if(!isset($this->translator)) | 
| @@ -147,12 +147,12 @@ discard block | ||
| 147 | 147 | return $this->translator; | 
| 148 | 148 | } | 
| 149 | 149 | |
| 150 | - /** | |
| 151 | - * Creates the styler, which can be used to retrieve the | |
| 152 | - * CSS required to style the highlighted commands in HTML. | |
| 153 | - * | |
| 154 | - * @return Mailcode_Styler | |
| 155 | - */ | |
| 150 | + /** | |
| 151 | + * Creates the styler, which can be used to retrieve the | |
| 152 | + * CSS required to style the highlighted commands in HTML. | |
| 153 | + * | |
| 154 | + * @return Mailcode_Styler | |
| 155 | + */ | |
| 156 | 156 | public function createStyler() : Mailcode_Styler | 
| 157 | 157 |      { | 
| 158 | 158 | return new Mailcode_Styler(); | 
| @@ -20,9 +20,9 @@ discard block | ||
| 20 | 20 | */ | 
| 21 | 21 | class Mailcode_Variables_Collection_Regular extends Mailcode_Variables_Collection | 
| 22 | 22 |  { | 
| 23 | - /** | |
| 24 | - * @var Mailcode_Variables_Collection_Invalid | |
| 25 | - */ | |
| 23 | + /** | |
| 24 | + * @var Mailcode_Variables_Collection_Invalid | |
| 25 | + */ | |
| 26 | 26 | protected Mailcode_Variables_Collection_Invalid $invalid; | 
| 27 | 27 | |
| 28 | 28 | protected function init() : void | 
| @@ -47,30 +47,30 @@ discard block | ||
| 47 | 47 | return $this; | 
| 48 | 48 | } | 
| 49 | 49 | |
| 50 | - /** | |
| 51 | - * Whether any of the variables in the collection are invalid. | |
| 52 | - * | |
| 53 | - * @return bool | |
| 54 | - */ | |
| 50 | + /** | |
| 51 | + * Whether any of the variables in the collection are invalid. | |
| 52 | + * | |
| 53 | + * @return bool | |
| 54 | + */ | |
| 55 | 55 | public function hasInvalid() : bool | 
| 56 | 56 |      { | 
| 57 | 57 | return $this->invalid->hasVariables(); | 
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | - /** | |
| 61 | - * Retrieves the collection of invalid variables, if any. | |
| 62 | - * Behaves like a variables collection. | |
| 63 | - * | |
| 64 | - * @return Mailcode_Variables_Collection_Invalid | |
| 65 | - */ | |
| 60 | + /** | |
| 61 | + * Retrieves the collection of invalid variables, if any. | |
| 62 | + * Behaves like a variables collection. | |
| 63 | + * | |
| 64 | + * @return Mailcode_Variables_Collection_Invalid | |
| 65 | + */ | |
| 66 | 66 | public function getInvalid() : Mailcode_Variables_Collection_Invalid | 
| 67 | 67 |      { | 
| 68 | 68 | return $this->invalid; | 
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | - /** | |
| 72 | - * @return Mailcode_Variables_Collection_Regular | |
| 73 | - */ | |
| 71 | + /** | |
| 72 | + * @return Mailcode_Variables_Collection_Regular | |
| 73 | + */ | |
| 74 | 74 | public function mergeWith(Mailcode_Variables_Collection $collection) : Mailcode_Variables_Collection | 
| 75 | 75 |      { | 
| 76 | 76 | parent::mergeWith($collection); | 
| @@ -26,7 +26,7 @@ discard block | ||
| 26 | 26 | |
| 27 | 27 | public function add(Mailcode_Variables_Variable $variable) : Mailcode_Variables_Collection | 
| 28 | 28 |      { | 
| 29 | - if($variable->isValid()) | |
| 29 | + if ($variable->isValid()) | |
| 30 | 30 |          { | 
| 31 | 31 | return $this; | 
| 32 | 32 | } | 
| @@ -38,7 +38,7 @@ discard block | ||
| 38 | 38 |      { | 
| 39 | 39 | $first = $this->getFirst(); | 
| 40 | 40 | |
| 41 | - if($first) | |
| 41 | + if ($first) | |
| 42 | 42 |          { | 
| 43 | 43 | return $first->getValidationResult(); | 
| 44 | 44 | } | 
| @@ -32,34 +32,34 @@ | ||
| 32 | 32 | public const VALIDATION_ERROR_PATH_UNDERSCORE = 48203; | 
| 33 | 33 | public const VALIDATION_ERROR_NAME_UNDERSCORE = 48204; | 
| 34 | 34 | |
| 35 | - /** | |
| 36 | - * @var string | |
| 37 | - */ | |
| 35 | + /** | |
| 36 | + * @var string | |
| 37 | + */ | |
| 38 | 38 | protected string $path; | 
| 39 | 39 | |
| 40 | - /** | |
| 41 | - * @var string | |
| 42 | - */ | |
| 40 | + /** | |
| 41 | + * @var string | |
| 42 | + */ | |
| 43 | 43 | protected string $name; | 
| 44 | 44 | |
| 45 | - /** | |
| 46 | - * @var string | |
| 47 | - */ | |
| 45 | + /** | |
| 46 | + * @var string | |
| 47 | + */ | |
| 48 | 48 | protected string $matchedText; | 
| 49 | 49 | |
| 50 | - /** | |
| 51 | - * @var string | |
| 52 | - */ | |
| 50 | + /** | |
| 51 | + * @var string | |
| 52 | + */ | |
| 53 | 53 | protected string $hash = ''; | 
| 54 | 54 | |
| 55 | - /** | |
| 56 | - * @var OperationResult|NULL | |
| 57 | - */ | |
| 55 | + /** | |
| 56 | + * @var OperationResult|NULL | |
| 57 | + */ | |
| 58 | 58 | protected ?OperationResult $validationResult = null; | 
| 59 | 59 | |
| 60 | - /** | |
| 61 | - * @var array<string> | |
| 62 | - */ | |
| 60 | + /** | |
| 61 | + * @var array<string> | |
| 62 | + */ | |
| 63 | 63 | protected $validations = array( | 
| 64 | 64 | 'number_path', | 
| 65 | 65 | 'number_name', | 
| @@ -72,7 +72,7 @@ discard block | ||
| 72 | 72 | */ | 
| 73 | 73 | private ?Mailcode_Commands_Command $command; | 
| 74 | 74 | |
| 75 | - public function __construct(string $path, string $name, string $matchedText, ?Mailcode_Commands_Command $sourceCommand=null) | |
| 75 | + public function __construct(string $path, string $name, string $matchedText, ?Mailcode_Commands_Command $sourceCommand = null) | |
| 76 | 76 |      { | 
| 77 | 77 | $this->path = $path; | 
| 78 | 78 | $this->name = $name; | 
| @@ -95,7 +95,7 @@ discard block | ||
| 95 | 95 | |
| 96 | 96 | public function getFullName() : string | 
| 97 | 97 |      { | 
| 98 | - if(empty($this->path)) | |
| 98 | + if (empty($this->path)) | |
| 99 | 99 |          { | 
| 100 | 100 | return '$'.$this->name; | 
| 101 | 101 | } | 
| @@ -113,7 +113,7 @@ discard block | ||
| 113 | 113 | */ | 
| 114 | 114 | public function getUniqueName() : string | 
| 115 | 115 |      { | 
| 116 | - if(isset($this->command)) | |
| 116 | + if (isset($this->command)) | |
| 117 | 117 |          { | 
| 118 | 118 | return $this->getFullName().'/'.$this->command->getHash(); | 
| 119 | 119 | } | 
| @@ -138,7 +138,7 @@ discard block | ||
| 138 | 138 | |
| 139 | 139 | public function getHash() : string | 
| 140 | 140 |      { | 
| 141 | - if(empty($this->hash)) | |
| 141 | + if (empty($this->hash)) | |
| 142 | 142 |          { | 
| 143 | 143 | $this->hash = md5($this->matchedText); | 
| 144 | 144 | } | 
| @@ -157,7 +157,7 @@ discard block | ||
| 157 | 157 | */ | 
| 158 | 158 | public function getValidationResult() : OperationResult | 
| 159 | 159 |      { | 
| 160 | - if(isset($this->validationResult)) | |
| 160 | + if (isset($this->validationResult)) | |
| 161 | 161 |          { | 
| 162 | 162 | return $this->validationResult; | 
| 163 | 163 | } | 
| @@ -171,11 +171,11 @@ discard block | ||
| 171 | 171 | |
| 172 | 172 | protected function validate(OperationResult $result) : void | 
| 173 | 173 |      { | 
| 174 | - foreach($this->validations as $validation) | |
| 174 | + foreach ($this->validations as $validation) | |
| 175 | 175 |          { | 
| 176 | 176 | $method = 'validate_'.$validation; | 
| 177 | 177 | |
| 178 | - if(!method_exists($this, $method)) | |
| 178 | + if (!method_exists($this, $method)) | |
| 179 | 179 |              { | 
| 180 | 180 | throw new Mailcode_Exception( | 
| 181 | 181 | 'Unknown validation method', | 
| @@ -220,7 +220,7 @@ discard block | ||
| 220 | 220 | |
| 221 | 221 | protected function validateNumber(string $value, int $errorCode) : void | 
| 222 | 222 |      { | 
| 223 | - if(!is_numeric(substr($value, 0, 1))) | |
| 223 | + if (!is_numeric(substr($value, 0, 1))) | |
| 224 | 224 |          { | 
| 225 | 225 | return; | 
| 226 | 226 | } | 
| @@ -238,7 +238,7 @@ discard block | ||
| 238 | 238 | protected function validateUnderscore(string $value, int $errorCode) : void | 
| 239 | 239 |      { | 
| 240 | 240 | // allow empty paths | 
| 241 | - if(empty($value)) | |
| 241 | + if (empty($value)) | |
| 242 | 242 |          { | 
| 243 | 243 | return; | 
| 244 | 244 | } | 
| @@ -246,7 +246,7 @@ discard block | ||
| 246 | 246 | $length = strlen($value); | 
| 247 | 247 | |
| 248 | 248 | // trimming underscores does not change the length: no underscores at start or end of string. | 
| 249 | - if(strlen(trim($value, '_')) === $length) | |
| 249 | + if (strlen(trim($value, '_')) === $length) | |
| 250 | 250 |          { | 
| 251 | 251 | return; | 
| 252 | 252 | } | 
| @@ -20,9 +20,9 @@ discard block | ||
| 20 | 20 | */ | 
| 21 | 21 | abstract class Mailcode_Variables_Collection | 
| 22 | 22 |  { | 
| 23 | - /** | |
| 24 | - * @var Mailcode_Variables_Variable[] | |
| 25 | - */ | |
| 23 | + /** | |
| 24 | + * @var Mailcode_Variables_Variable[] | |
| 25 | + */ | |
| 26 | 26 | protected array $variables = array(); | 
| 27 | 27 | |
| 28 | 28 | public function __construct() | 
| @@ -52,12 +52,12 @@ discard block | ||
| 52 | 52 | return count($this->variables); | 
| 53 | 53 | } | 
| 54 | 54 | |
| 55 | - /** | |
| 56 | - * Checks whether the collection contains a variable with the specified name. | |
| 57 | - * | |
| 58 | - * @param string $fullName The variable name, with or without $ sign. | |
| 59 | - * @return bool | |
| 60 | - */ | |
| 55 | + /** | |
| 56 | + * Checks whether the collection contains a variable with the specified name. | |
| 57 | + * | |
| 58 | + * @param string $fullName The variable name, with or without $ sign. | |
| 59 | + * @return bool | |
| 60 | + */ | |
| 61 | 61 | public function hasVariableName(string $fullName) : bool | 
| 62 | 62 |      { | 
| 63 | 63 | $fullName = $this->fixName($fullName); | 
| @@ -73,14 +73,14 @@ discard block | ||
| 73 | 73 | return false; | 
| 74 | 74 | } | 
| 75 | 75 | |
| 76 | - /** | |
| 77 | - * Retrieves a collection of all variable instances for | |
| 78 | - * the specified name (there can be several with differing | |
| 79 | - * matched texts because of spacing). | |
| 80 | - * | |
| 81 | - * @param string $fullName | |
| 82 | - * @return Mailcode_Variables_Collection | |
| 83 | - */ | |
| 76 | + /** | |
| 77 | + * Retrieves a collection of all variable instances for | |
| 78 | + * the specified name (there can be several with differing | |
| 79 | + * matched texts because of spacing). | |
| 80 | + * | |
| 81 | + * @param string $fullName | |
| 82 | + * @return Mailcode_Variables_Collection | |
| 83 | + */ | |
| 84 | 84 | public function getByFullName(string $fullName) : Mailcode_Variables_Collection | 
| 85 | 85 |      { | 
| 86 | 86 | $fullName = $this->fixName($fullName); | 
| @@ -98,12 +98,12 @@ discard block | ||
| 98 | 98 | return $collection; | 
| 99 | 99 | } | 
| 100 | 100 | |
| 101 | - /** | |
| 102 | - * Prepends the $ sign to a variable name if it does not have it. | |
| 103 | - * | |
| 104 | - * @param string $fullName | |
| 105 | - * @return string | |
| 106 | - */ | |
| 101 | + /** | |
| 102 | + * Prepends the $ sign to a variable name if it does not have it. | |
| 103 | + * | |
| 104 | + * @param string $fullName | |
| 105 | + * @return string | |
| 106 | + */ | |
| 107 | 107 | protected function fixName(string $fullName) : string | 
| 108 | 108 |      { | 
| 109 | 109 | if(substr($fullName, 0, 1) === '$') | 
| @@ -114,12 +114,12 @@ discard block | ||
| 114 | 114 | return '$'.$fullName; | 
| 115 | 115 | } | 
| 116 | 116 | |
| 117 | - /** | |
| 118 | - * Retrieves all variables, grouped by their hash - meaning | |
| 119 | - * unique matched strings. | |
| 120 | - * | |
| 121 | - * @return Mailcode_Variables_Variable[] | |
| 122 | - */ | |
| 117 | + /** | |
| 118 | + * Retrieves all variables, grouped by their hash - meaning | |
| 119 | + * unique matched strings. | |
| 120 | + * | |
| 121 | + * @return Mailcode_Variables_Variable[] | |
| 122 | + */ | |
| 123 | 123 | public function getGroupedByHash() : array | 
| 124 | 124 |      { | 
| 125 | 125 | $entries = array(); | 
| @@ -132,11 +132,11 @@ discard block | ||
| 132 | 132 | return $this->sortVariables($entries); | 
| 133 | 133 | } | 
| 134 | 134 | |
| 135 | - /** | |
| 136 | - * Retrieves all variables, grouped by their name. | |
| 137 | - * | |
| 138 | - * @return Mailcode_Variables_Variable[] | |
| 139 | - */ | |
| 135 | + /** | |
| 136 | + * Retrieves all variables, grouped by their name. | |
| 137 | + * | |
| 138 | + * @return Mailcode_Variables_Variable[] | |
| 139 | + */ | |
| 140 | 140 | public function getGroupedByName() : array | 
| 141 | 141 |      { | 
| 142 | 142 | $entries = array(); | 
| @@ -168,19 +168,19 @@ discard block | ||
| 168 | 168 | return $this->sortVariables($entries); | 
| 169 | 169 | } | 
| 170 | 170 | |
| 171 | - /** | |
| 172 | - * Retrieves all variables, in the order they were addded. | |
| 173 | - * @return Mailcode_Variables_Variable[] | |
| 174 | - */ | |
| 171 | + /** | |
| 172 | + * Retrieves all variables, in the order they were addded. | |
| 173 | + * @return Mailcode_Variables_Variable[] | |
| 174 | + */ | |
| 175 | 175 | public function getAll() | 
| 176 | 176 |      { | 
| 177 | 177 | return $this->variables; | 
| 178 | 178 | } | 
| 179 | 179 | |
| 180 | - /** | |
| 181 | - * Retrieves the full names of the variables that are present in the collection. | |
| 182 | - * @return string[] | |
| 183 | - */ | |
| 180 | + /** | |
| 181 | + * Retrieves the full names of the variables that are present in the collection. | |
| 182 | + * @return string[] | |
| 183 | + */ | |
| 184 | 184 | public function getNames() : array | 
| 185 | 185 |      { | 
| 186 | 186 | $result = array(); | 
| @@ -198,13 +198,13 @@ discard block | ||
| 198 | 198 | return $result; | 
| 199 | 199 | } | 
| 200 | 200 | |
| 201 | - /** | |
| 202 | - * Takes a list of variables and sorts them, throwing away | |
| 203 | - * the source array's keys. | |
| 204 | - * | |
| 205 | - * @param Mailcode_Variables_Variable[] $entries | |
| 206 | - * @return Mailcode_Variables_Variable[] | |
| 207 | - */ | |
| 201 | + /** | |
| 202 | + * Takes a list of variables and sorts them, throwing away | |
| 203 | + * the source array's keys. | |
| 204 | + * | |
| 205 | + * @param Mailcode_Variables_Variable[] $entries | |
| 206 | + * @return Mailcode_Variables_Variable[] | |
| 207 | + */ | |
| 208 | 208 | protected function sortVariables(array $entries) | 
| 209 | 209 |      { | 
| 210 | 210 | $result = array_values($entries); | 
| @@ -217,13 +217,13 @@ discard block | ||
| 217 | 217 | return $result; | 
| 218 | 218 | } | 
| 219 | 219 | |
| 220 | - /** | |
| 221 | - * Merges the variables collection with the target collection | |
| 222 | - * by inheriting all that collection's variables. | |
| 223 | - * | |
| 224 | - * @param Mailcode_Variables_Collection $collection | |
| 225 | - * @return Mailcode_Variables_Collection | |
| 226 | - */ | |
| 220 | + /** | |
| 221 | + * Merges the variables collection with the target collection | |
| 222 | + * by inheriting all that collection's variables. | |
| 223 | + * | |
| 224 | + * @param Mailcode_Variables_Collection $collection | |
| 225 | + * @return Mailcode_Variables_Collection | |
| 226 | + */ | |
| 227 | 227 | public function mergeWith(Mailcode_Variables_Collection $collection) : Mailcode_Variables_Collection | 
| 228 | 228 |      { | 
| 229 | 229 | $variables = $collection->getGroupedByHash(); | 
| @@ -111,7 +111,7 @@ discard block | ||
| 111 | 111 | */ | 
| 112 | 112 | public static function getContent(int $id) : string | 
| 113 | 113 |      { | 
| 114 | - if(isset(self::$contents[$id])) | |
| 114 | + if (isset(self::$contents[$id])) | |
| 115 | 115 |          { | 
| 116 | 116 | return self::$contents[$id]; | 
| 117 | 117 | } | 
| @@ -134,7 +134,7 @@ discard block | ||
| 134 | 134 | */ | 
| 135 | 135 | public static function clearContent(int $id) : void | 
| 136 | 136 |      { | 
| 137 | - if(isset(self::$contents[$id])) | |
| 137 | + if (isset(self::$contents[$id])) | |
| 138 | 138 |          { | 
| 139 | 139 | unset(self::$contents[$id]); | 
| 140 | 140 | } | 
| @@ -155,7 +155,7 @@ discard block | ||
| 155 | 155 | |
| 156 | 156 | $names = $this->getContentCommandNames(); | 
| 157 | 157 | |
| 158 | - foreach($names as $name) | |
| 158 | + foreach ($names as $name) | |
| 159 | 159 |          { | 
| 160 | 160 | $this->collapseContentCommand($name); | 
| 161 | 161 | } | 
| @@ -174,7 +174,7 @@ discard block | ||
| 174 | 174 | $commands = Mailcode::create()->getCommands()->getContentCommands(); | 
| 175 | 175 | $result = array(); | 
| 176 | 176 | |
| 177 | - foreach($commands as $command) | |
| 177 | + foreach ($commands as $command) | |
| 178 | 178 |          { | 
| 179 | 179 | $result[] = $command->getName(); | 
| 180 | 180 | } | 
| @@ -245,7 +245,7 @@ discard block | ||
| 245 | 245 |      { | 
| 246 | 246 | $this->commands = $this->detectCommands($name); | 
| 247 | 247 | |
| 248 | - foreach($this->commands as $commandDef) | |
| 248 | + foreach ($this->commands as $commandDef) | |
| 249 | 249 |          { | 
| 250 | 250 | $this->processCommand($commandDef); | 
| 251 | 251 | } | 
| @@ -255,9 +255,9 @@ discard block | ||
| 255 | 255 | |
| 256 | 256 | private function validateCommandContents() : void | 
| 257 | 257 |      { | 
| 258 | - foreach($this->commands as $command) | |
| 258 | + foreach ($this->commands as $command) | |
| 259 | 259 |          { | 
| 260 | - if(!$command->validateContent($this, $this->collection)) | |
| 260 | + if (!$command->validateContent($this, $this->collection)) | |
| 261 | 261 |              { | 
| 262 | 262 | return; | 
| 263 | 263 | } | 
| @@ -271,14 +271,14 @@ discard block | ||
| 271 | 271 |      { | 
| 272 | 272 | $openingCommands = $this->detectOpeningCommands($name); | 
| 273 | 273 | |
| 274 | - if(empty($openingCommands)) | |
| 274 | + if (empty($openingCommands)) | |
| 275 | 275 |          { | 
| 276 | 276 | return array(); | 
| 277 | 277 | } | 
| 278 | 278 | |
| 279 | 279 | $closingCommands = $this->detectClosingCommands($name); | 
| 280 | 280 | |
| 281 | - if(count($closingCommands) !== count($openingCommands)) | |
| 281 | + if (count($closingCommands) !== count($openingCommands)) | |
| 282 | 282 |          { | 
| 283 | 283 | $this->addClosingError($name); | 
| 284 | 284 | return array(); | 
| @@ -286,7 +286,7 @@ discard block | ||
| 286 | 286 | |
| 287 | 287 | $result = array(); | 
| 288 | 288 | |
| 289 | - foreach($openingCommands as $idx => $def) | |
| 289 | + foreach ($openingCommands as $idx => $def) | |
| 290 | 290 |          { | 
| 291 | 291 | $result[] = new Mailcode_PreParser_CommandDef( | 
| 292 | 292 | $name, | 
| @@ -328,7 +328,7 @@ discard block | ||
| 328 | 328 | */ | 
| 329 | 329 | private function debugOpeningCommands(array $matches) : void | 
| 330 | 330 |      { | 
| 331 | - if($this->debug === false) | |
| 331 | + if ($this->debug === false) | |
| 332 | 332 |          { | 
| 333 | 333 | return; | 
| 334 | 334 | } | 
| @@ -382,7 +382,7 @@ discard block | ||
| 382 | 382 | |
| 383 | 383 | private function debugCommandDef(Mailcode_PreParser_CommandDef $commandDef) : void | 
| 384 | 384 |      { | 
| 385 | - if($this->debug === true) | |
| 385 | + if ($this->debug === true) | |
| 386 | 386 |          { | 
| 387 | 387 | echo 'Command definition:'.PHP_EOL; | 
| 388 | 388 | print_r($commandDef->toArray()); | 
| @@ -26,24 +26,24 @@ discard block | ||
| 26 | 26 | public const VALIDATION_EMPTY = 48801; | 
| 27 | 27 | public const VALIDATION_UNQUOTED_STRING_LITERALS = 48802; | 
| 28 | 28 | |
| 29 | - /** | |
| 30 | - * @var string | |
| 31 | - */ | |
| 29 | + /** | |
| 30 | + * @var string | |
| 31 | + */ | |
| 32 | 32 | protected string $statement; | 
| 33 | 33 | |
| 34 | - /** | |
| 35 | - * @var OperationResult | |
| 36 | - */ | |
| 34 | + /** | |
| 35 | + * @var OperationResult | |
| 36 | + */ | |
| 37 | 37 | protected OperationResult $result; | 
| 38 | 38 | |
| 39 | - /** | |
| 40 | - * @var Mailcode_Parser_Statement_Tokenizer | |
| 41 | - */ | |
| 39 | + /** | |
| 40 | + * @var Mailcode_Parser_Statement_Tokenizer | |
| 41 | + */ | |
| 42 | 42 | protected Mailcode_Parser_Statement_Tokenizer $tokenizer; | 
| 43 | 43 | |
| 44 | - /** | |
| 45 | - * @var Mailcode_Parser_Statement_Info|NULL | |
| 46 | - */ | |
| 44 | + /** | |
| 45 | + * @var Mailcode_Parser_Statement_Info|NULL | |
| 46 | + */ | |
| 47 | 47 | protected ?Mailcode_Parser_Statement_Info $info = null; | 
| 48 | 48 | |
| 49 | 49 | /** | 
| @@ -138,7 +138,7 @@ discard block | ||
| 138 | 138 | if($unknown) | 
| 139 | 139 |          { | 
| 140 | 140 | $this->result->makeError( | 
| 141 | -               t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')', | |
| 141 | +                t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')', | |
| 142 | 142 | self::VALIDATION_UNQUOTED_STRING_LITERALS | 
| 143 | 143 | ); | 
| 144 | 144 | } | 
| @@ -56,7 +56,7 @@ discard block | ||
| 56 | 56 | */ | 
| 57 | 57 | private ?Mailcode_Commands_Command $sourceCommand = null; | 
| 58 | 58 | |
| 59 | - public function __construct(string $statement, bool $freeform=false, ?Mailcode_Commands_Command $sourceCommand=null) | |
| 59 | + public function __construct(string $statement, bool $freeform = false, ?Mailcode_Commands_Command $sourceCommand = null) | |
| 60 | 60 |      { | 
| 61 | 61 | $this->sourceCommand = $sourceCommand; | 
| 62 | 62 | $this->statement = $this->prepareStatement($statement); | 
| @@ -106,7 +106,7 @@ discard block | ||
| 106 | 106 | |
| 107 | 107 | public function getInfo() : Mailcode_Parser_Statement_Info | 
| 108 | 108 |      { | 
| 109 | - if($this->info instanceof Mailcode_Parser_Statement_Info) | |
| 109 | + if ($this->info instanceof Mailcode_Parser_Statement_Info) | |
| 110 | 110 |          { | 
| 111 | 111 | return $this->info; | 
| 112 | 112 | } | 
| @@ -118,12 +118,12 @@ discard block | ||
| 118 | 118 | |
| 119 | 119 | protected function validate() : void | 
| 120 | 120 |      { | 
| 121 | - if($this->freeform) | |
| 121 | + if ($this->freeform) | |
| 122 | 122 |          { | 
| 123 | 123 | return; | 
| 124 | 124 | } | 
| 125 | 125 | |
| 126 | - if(!$this->tokenizer->hasTokens()) | |
| 126 | + if (!$this->tokenizer->hasTokens()) | |
| 127 | 127 |          { | 
| 128 | 128 | $this->result->makeError( | 
| 129 | 129 |                  t('Empty statement'), | 
| @@ -135,7 +135,7 @@ discard block | ||
| 135 | 135 | |
| 136 | 136 | $unknown = $this->tokenizer->getFirstUnknown(); | 
| 137 | 137 | |
| 138 | - if($unknown) | |
| 138 | + if ($unknown) | |
| 139 | 139 |          { | 
| 140 | 140 | $this->result->makeError( | 
| 141 | 141 |                 t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')', | 
| @@ -139,11 +139,11 @@ | ||
| 139 | 139 | $commands = $parser->getCommands(); | 
| 140 | 140 | $content = $this->getContent(); | 
| 141 | 141 | |
| 142 | - foreach($commands as $command) | |
| 142 | + foreach ($commands as $command) | |
| 143 | 143 |          { | 
| 144 | 144 | $string = $command->getOpeningText(); | 
| 145 | 145 | |
| 146 | - if(strpos($content, $string) !== false) | |
| 146 | + if (strpos($content, $string) !== false) | |
| 147 | 147 |              { | 
| 148 | 148 | $this->addEscapeError($command, $collection); | 
| 149 | 149 | return false; | 
| @@ -54,40 +54,40 @@ discard block | ||
| 54 | 54 | public const ERROR_NO_PLACEHOLDER_FOR_COMMAND = 47805; | 
| 55 | 55 | public const ERROR_NO_FIRST_PLACEHOLDER = 47806; | 
| 56 | 56 | |
| 57 | - /** | |
| 58 | - * @var Mailcode_Parser | |
| 59 | - */ | |
| 57 | + /** | |
| 58 | + * @var Mailcode_Parser | |
| 59 | + */ | |
| 60 | 60 | protected Mailcode_Parser $parser; | 
| 61 | 61 | |
| 62 | - /** | |
| 63 | - * @var Mailcode_Collection | |
| 64 | - */ | |
| 62 | + /** | |
| 63 | + * @var Mailcode_Collection | |
| 64 | + */ | |
| 65 | 65 | protected Mailcode_Collection $commands; | 
| 66 | 66 | |
| 67 | - /** | |
| 68 | - * @var string | |
| 69 | - */ | |
| 67 | + /** | |
| 68 | + * @var string | |
| 69 | + */ | |
| 70 | 70 | protected string $originalString; | 
| 71 | 71 | |
| 72 | - /** | |
| 73 | - * @var Mailcode_Collection | |
| 74 | - */ | |
| 72 | + /** | |
| 73 | + * @var Mailcode_Collection | |
| 74 | + */ | |
| 75 | 75 | protected Mailcode_Collection $collection; | 
| 76 | 76 | |
| 77 | - /** | |
| 78 | - * Counter for the placeholders, global for all placeholders. | |
| 79 | - * @var integer | |
| 80 | - */ | |
| 77 | + /** | |
| 78 | + * Counter for the placeholders, global for all placeholders. | |
| 79 | + * @var integer | |
| 80 | + */ | |
| 81 | 81 | private static int $counter = 0; | 
| 82 | 82 | |
| 83 | - /** | |
| 84 | - * @var Mailcode_Parser_Safeguard_PlaceholderCollection|NULL | |
| 85 | - */ | |
| 83 | + /** | |
| 84 | + * @var Mailcode_Parser_Safeguard_PlaceholderCollection|NULL | |
| 85 | + */ | |
| 86 | 86 | protected ?Mailcode_Parser_Safeguard_PlaceholderCollection $placeholders = null; | 
| 87 | 87 | |
| 88 | - /** | |
| 89 | - * @var string | |
| 90 | - */ | |
| 88 | + /** | |
| 89 | + * @var string | |
| 90 | + */ | |
| 91 | 91 | protected string $delimiter = '999'; | 
| 92 | 92 | |
| 93 | 93 | public function __construct(Mailcode_Parser $parser, string $subject) | 
| @@ -106,28 +106,28 @@ discard block | ||
| 106 | 106 | self::$counter = 0; | 
| 107 | 107 | } | 
| 108 | 108 | |
| 109 | - /** | |
| 110 | - * Retrieves the string the safeguard was created for. | |
| 111 | - * | |
| 112 | - * @return string | |
| 113 | - */ | |
| 109 | + /** | |
| 110 | + * Retrieves the string the safeguard was created for. | |
| 111 | + * | |
| 112 | + * @return string | |
| 113 | + */ | |
| 114 | 114 | public function getOriginalString() : string | 
| 115 | 115 |      { | 
| 116 | 116 | return $this->originalString; | 
| 117 | 117 | } | 
| 118 | 118 | |
| 119 | - /** | |
| 120 | - * Sets the delimiter character sequence used to prepend | |
| 121 | - * and append to the placeholders. | |
| 122 | - * | |
| 123 | - * The delimiter's default is "999". | |
| 124 | - * | |
| 125 | - * Minimum characters: 2 | |
| 126 | - * Invalid characters: Any characters that get URL encoded | |
| 127 | - * | |
| 128 | - * @param string $delimiter | |
| 129 | - * @return Mailcode_Parser_Safeguard | |
| 130 | - */ | |
| 119 | + /** | |
| 120 | + * Sets the delimiter character sequence used to prepend | |
| 121 | + * and append to the placeholders. | |
| 122 | + * | |
| 123 | + * The delimiter's default is "999". | |
| 124 | + * | |
| 125 | + * Minimum characters: 2 | |
| 126 | + * Invalid characters: Any characters that get URL encoded | |
| 127 | + * | |
| 128 | + * @param string $delimiter | |
| 129 | + * @return Mailcode_Parser_Safeguard | |
| 130 | + */ | |
| 131 | 131 | public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard | 
| 132 | 132 |      { | 
| 133 | 133 | $validator = new Mailcode_Parser_Safeguard_DelimiterValidator($delimiter); | 
| @@ -143,15 +143,15 @@ discard block | ||
| 143 | 143 | return $this->delimiter; | 
| 144 | 144 | } | 
| 145 | 145 | |
| 146 | - /** | |
| 147 | - * Retrieves the safe string in which all commands have been replaced | |
| 148 | - * by placeholder strings. | |
| 149 | - * | |
| 150 | - * @return string | |
| 151 | - * @throws Mailcode_Exception | |
| 152 | - * | |
| 153 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS | |
| 154 | - */ | |
| 146 | + /** | |
| 147 | + * Retrieves the safe string in which all commands have been replaced | |
| 148 | + * by placeholder strings. | |
| 149 | + * | |
| 150 | + * @return string | |
| 151 | + * @throws Mailcode_Exception | |
| 152 | + * | |
| 153 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS | |
| 154 | + */ | |
| 155 | 155 | public function makeSafe() : string | 
| 156 | 156 |      { | 
| 157 | 157 | $this->requireValidCollection(); | 
| @@ -159,16 +159,16 @@ discard block | ||
| 159 | 159 | return $this->makeSafePartial(); | 
| 160 | 160 | } | 
| 161 | 161 | |
| 162 | - /** | |
| 163 | - * Like makeSafe(), but allows partial (invalid) commands: use this | |
| 164 | - * if the subject string may contain only part of the whole set of | |
| 165 | - * commands. | |
| 166 | - * | |
| 167 | - * Example: parsing a text with an opening if statement, without the | |
| 168 | - * matching end statement. | |
| 169 | - * | |
| 170 | - * @return string | |
| 171 | - */ | |
| 162 | + /** | |
| 163 | + * Like makeSafe(), but allows partial (invalid) commands: use this | |
| 164 | + * if the subject string may contain only part of the whole set of | |
| 165 | + * commands. | |
| 166 | + * | |
| 167 | + * Example: parsing a text with an opening if statement, without the | |
| 168 | + * matching end statement. | |
| 169 | + * | |
| 170 | + * @return string | |
| 171 | + */ | |
| 172 | 172 | public function makeSafePartial() : string | 
| 173 | 173 |      { | 
| 174 | 174 | $placeholders = $this->getPlaceholdersCollection()->getAll(); | 
| @@ -218,13 +218,13 @@ discard block | ||
| 218 | 218 | $analyzer->analyze(); | 
| 219 | 219 | } | 
| 220 | 220 | |
| 221 | - /** | |
| 222 | - * Creates a formatting handler, which can be used to specify | |
| 223 | - * which formatting to use for the commands in the subject string. | |
| 224 | - * | |
| 225 | - * @param Mailcode_StringContainer|string $subject | |
| 226 | - * @return Mailcode_Parser_Safeguard_Formatting | |
| 227 | - */ | |
| 221 | + /** | |
| 222 | + * Creates a formatting handler, which can be used to specify | |
| 223 | + * which formatting to use for the commands in the subject string. | |
| 224 | + * | |
| 225 | + * @param Mailcode_StringContainer|string $subject | |
| 226 | + * @return Mailcode_Parser_Safeguard_Formatting | |
| 227 | + */ | |
| 228 | 228 | public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting | 
| 229 | 229 |      { | 
| 230 | 230 | if(is_string($subject)) | 
| @@ -249,11 +249,11 @@ discard block | ||
| 249 | 249 | } | 
| 250 | 250 | |
| 251 | 251 | /** | 
| 252 | - * Retrieves all placeholders that have to be added to | |
| 253 | - * the subject text. | |
| 254 | - * | |
| 255 | - * @return Mailcode_Parser_Safeguard_PlaceholderCollection | |
| 256 | - */ | |
| 252 | + * Retrieves all placeholders that have to be added to | |
| 253 | + * the subject text. | |
| 254 | + * | |
| 255 | + * @return Mailcode_Parser_Safeguard_PlaceholderCollection | |
| 256 | + */ | |
| 257 | 257 | public function getPlaceholdersCollection() : Mailcode_Parser_Safeguard_PlaceholderCollection | 
| 258 | 258 |      { | 
| 259 | 259 | if(isset($this->placeholders)) | 
| @@ -313,16 +313,16 @@ discard block | ||
| 313 | 313 | return $formatting->toString(); | 
| 314 | 314 | } | 
| 315 | 315 | |
| 316 | - /** | |
| 317 | - * Makes the string whole again after transforming or filtering it, | |
| 318 | - * by replacing the command placeholders with the original commands. | |
| 319 | - * | |
| 320 | - * @param string $string | |
| 321 | - * @return string | |
| 322 | - * @throws Mailcode_Exception | |
| 323 | - * | |
| 324 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS | |
| 325 | - */ | |
| 316 | + /** | |
| 317 | + * Makes the string whole again after transforming or filtering it, | |
| 318 | + * by replacing the command placeholders with the original commands. | |
| 319 | + * | |
| 320 | + * @param string $string | |
| 321 | + * @return string | |
| 322 | + * @throws Mailcode_Exception | |
| 323 | + * | |
| 324 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS | |
| 325 | + */ | |
| 326 | 326 | public function makeWhole(string $string) : string | 
| 327 | 327 |      { | 
| 328 | 328 | return $this->restore( | 
| @@ -332,15 +332,15 @@ discard block | ||
| 332 | 332 | ); | 
| 333 | 333 | } | 
| 334 | 334 | |
| 335 | - /** | |
| 336 | - * Like `makeWhole()`, but ignores missing command placeholders. | |
| 337 | - * | |
| 338 | - * @param string $string | |
| 339 | - * @return string | |
| 340 | - * @throws Mailcode_Exception | |
| 341 | - * | |
| 342 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS | |
| 343 | - */ | |
| 335 | + /** | |
| 336 | + * Like `makeWhole()`, but ignores missing command placeholders. | |
| 337 | + * | |
| 338 | + * @param string $string | |
| 339 | + * @return string | |
| 340 | + * @throws Mailcode_Exception | |
| 341 | + * | |
| 342 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS | |
| 343 | + */ | |
| 344 | 344 | public function makeWholePartial(string $string) : string | 
| 345 | 345 |      { | 
| 346 | 346 | return $this->restore( | 
| @@ -350,19 +350,19 @@ discard block | ||
| 350 | 350 | ); | 
| 351 | 351 | } | 
| 352 | 352 | |
| 353 | - /** | |
| 354 | - * Like `makeWhole()`, but replaces the commands with a syntax | |
| 355 | - * highlighted version, meant for human readable texts only. | |
| 356 | - * | |
| 357 | - * Note: the commands lose their functionality (They cannot be | |
| 358 | - * parsed from that string again). | |
| 359 | - * | |
| 360 | - * @param string $string | |
| 361 | - * @return string | |
| 362 | - * @throws Mailcode_Exception | |
| 363 | - * | |
| 364 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS | |
| 365 | - */ | |
| 353 | + /** | |
| 354 | + * Like `makeWhole()`, but replaces the commands with a syntax | |
| 355 | + * highlighted version, meant for human readable texts only. | |
| 356 | + * | |
| 357 | + * Note: the commands lose their functionality (They cannot be | |
| 358 | + * parsed from that string again). | |
| 359 | + * | |
| 360 | + * @param string $string | |
| 361 | + * @return string | |
| 362 | + * @throws Mailcode_Exception | |
| 363 | + * | |
| 364 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS | |
| 365 | + */ | |
| 366 | 366 | public function makeHighlighted(string $string) : string | 
| 367 | 367 |      { | 
| 368 | 368 | return $this->restore( | 
| @@ -372,15 +372,15 @@ discard block | ||
| 372 | 372 | ); | 
| 373 | 373 | } | 
| 374 | 374 | |
| 375 | - /** | |
| 376 | - * Like `makeHighlighted()`, but ignores missing command placeholders. | |
| 377 | - * | |
| 378 | - * @param string $string | |
| 379 | - * @return string | |
| 380 | - * @throws Mailcode_Exception | |
| 381 | - * | |
| 382 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS | |
| 383 | - */ | |
| 375 | + /** | |
| 376 | + * Like `makeHighlighted()`, but ignores missing command placeholders. | |
| 377 | + * | |
| 378 | + * @param string $string | |
| 379 | + * @return string | |
| 380 | + * @throws Mailcode_Exception | |
| 381 | + * | |
| 382 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS | |
| 383 | + */ | |
| 384 | 384 | public function makeHighlightedPartial(string $string) : string | 
| 385 | 385 |      { | 
| 386 | 386 | return $this->restore( | 
| @@ -390,11 +390,11 @@ discard block | ||
| 390 | 390 | ); | 
| 391 | 391 | } | 
| 392 | 392 | |
| 393 | - /** | |
| 394 | - * Retrieves the command collection contained in the string. | |
| 395 | - * | |
| 396 | - * @return Mailcode_Collection | |
| 397 | - */ | |
| 393 | + /** | |
| 394 | + * Retrieves the command collection contained in the string. | |
| 395 | + * | |
| 396 | + * @return Mailcode_Collection | |
| 397 | + */ | |
| 398 | 398 | public function getCollection() : Mailcode_Collection | 
| 399 | 399 |      { | 
| 400 | 400 | if(isset($this->collection)) | 
| @@ -418,11 +418,11 @@ discard block | ||
| 418 | 418 | return $this->getCollection()->isValid(); | 
| 419 | 419 | } | 
| 420 | 420 | |
| 421 | - /** | |
| 422 | - * @throws Mailcode_Exception | |
| 423 | - * | |
| 424 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS | |
| 425 | - */ | |
| 421 | + /** | |
| 422 | + * @throws Mailcode_Exception | |
| 423 | + * | |
| 424 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS | |
| 425 | + */ | |
| 426 | 426 | protected function requireValidCollection() : void | 
| 427 | 427 |      { | 
| 428 | 428 | if($this->getCollection()->isValid()) | 
| @@ -445,13 +445,13 @@ discard block | ||
| 445 | 445 | throw $exception; | 
| 446 | 446 | } | 
| 447 | 447 | |
| 448 | - /** | |
| 449 | - * Retrieves a list of all placeholder IDs used in the text. | |
| 450 | - * | |
| 451 | - * @return string[] | |
| 452 | - * | |
| 453 | -    * @deprecated Use the placeholder collection instead {@see Mailcode_Parser_Safeguard::getPlaceholdersCollection()}. | |
| 454 | - */ | |
| 448 | + /** | |
| 449 | + * Retrieves a list of all placeholder IDs used in the text. | |
| 450 | + * | |
| 451 | + * @return string[] | |
| 452 | + * | |
| 453 | +     * @deprecated Use the placeholder collection instead {@see Mailcode_Parser_Safeguard::getPlaceholdersCollection()}. | |
| 454 | + */ | |
| 455 | 455 | public function getPlaceholderStrings() : array | 
| 456 | 456 |      { | 
| 457 | 457 | return $this->getPlaceholdersCollection()->getStrings(); | 
| @@ -462,29 +462,29 @@ discard block | ||
| 462 | 462 | return $this->getPlaceholdersCollection()->isStringPlaceholder($subject); | 
| 463 | 463 | } | 
| 464 | 464 | |
| 465 | - /** | |
| 466 | - * Retrieves a placeholder instance by its ID. | |
| 467 | - * | |
| 468 | - * @param int $id | |
| 469 | - * @throws Mailcode_Exception If the placeholder was not found. | |
| 470 | - * @return Mailcode_Parser_Safeguard_Placeholder | |
| 471 | - * | |
| 472 | -    * @deprecated Use the placeholder collection instead {@see Mailcode_Parser_Safeguard::getPlaceholdersCollection()}. | |
| 473 | - */ | |
| 465 | + /** | |
| 466 | + * Retrieves a placeholder instance by its ID. | |
| 467 | + * | |
| 468 | + * @param int $id | |
| 469 | + * @throws Mailcode_Exception If the placeholder was not found. | |
| 470 | + * @return Mailcode_Parser_Safeguard_Placeholder | |
| 471 | + * | |
| 472 | +     * @deprecated Use the placeholder collection instead {@see Mailcode_Parser_Safeguard::getPlaceholdersCollection()}. | |
| 473 | + */ | |
| 474 | 474 | public function getPlaceholderByID(int $id) : Mailcode_Parser_Safeguard_Placeholder | 
| 475 | 475 |      { | 
| 476 | 476 | return $this->getPlaceholdersCollection()->getByID($id); | 
| 477 | 477 | } | 
| 478 | 478 | |
| 479 | - /** | |
| 480 | - * Retrieves a placeholder instance by its replacement text. | |
| 481 | - * | |
| 482 | - * @param string $string | |
| 483 | - * @throws Mailcode_Exception | |
| 484 | - * @return Mailcode_Parser_Safeguard_Placeholder | |
| 485 | - * | |
| 486 | -    * @deprecated Use the placeholder collection instead {@see Mailcode_Parser_Safeguard::getPlaceholdersCollection()}. | |
| 487 | - */ | |
| 479 | + /** | |
| 480 | + * Retrieves a placeholder instance by its replacement text. | |
| 481 | + * | |
| 482 | + * @param string $string | |
| 483 | + * @throws Mailcode_Exception | |
| 484 | + * @return Mailcode_Parser_Safeguard_Placeholder | |
| 485 | + * | |
| 486 | +     * @deprecated Use the placeholder collection instead {@see Mailcode_Parser_Safeguard::getPlaceholdersCollection()}. | |
| 487 | + */ | |
| 488 | 488 | public function getPlaceholderByString(string $string) : Mailcode_Parser_Safeguard_Placeholder | 
| 489 | 489 |      { | 
| 490 | 490 | return $this->getPlaceholdersCollection()->getByString($string); | 
| @@ -174,7 +174,7 @@ discard block | ||
| 174 | 174 | $placeholders = $this->getPlaceholdersCollection()->getAll(); | 
| 175 | 175 | $string = $this->originalString; | 
| 176 | 176 | |
| 177 | - foreach($placeholders as $placeholder) | |
| 177 | + foreach ($placeholders as $placeholder) | |
| 178 | 178 |          { | 
| 179 | 179 | $string = $this->makePlaceholderSafe($string, $placeholder); | 
| 180 | 180 | } | 
| @@ -188,7 +188,7 @@ discard block | ||
| 188 | 188 |      { | 
| 189 | 189 | $pos = mb_strpos($string, $placeholder->getOriginalText()); | 
| 190 | 190 | |
| 191 | - if($pos === false) | |
| 191 | + if ($pos === false) | |
| 192 | 192 |          { | 
| 193 | 193 | throw new Mailcode_Exception( | 
| 194 | 194 | 'Placeholder original text not found', | 
| @@ -227,7 +227,7 @@ discard block | ||
| 227 | 227 | */ | 
| 228 | 228 | public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting | 
| 229 | 229 |      { | 
| 230 | - if(is_string($subject)) | |
| 230 | + if (is_string($subject)) | |
| 231 | 231 |          { | 
| 232 | 232 | $subject = Mailcode::create()->createString($subject); | 
| 233 | 233 | } | 
| @@ -256,7 +256,7 @@ discard block | ||
| 256 | 256 | */ | 
| 257 | 257 | public function getPlaceholdersCollection() : Mailcode_Parser_Safeguard_PlaceholderCollection | 
| 258 | 258 |      { | 
| 259 | - if(isset($this->placeholders)) | |
| 259 | + if (isset($this->placeholders)) | |
| 260 | 260 |          { | 
| 261 | 261 | return $this->placeholders; | 
| 262 | 262 | } | 
| @@ -264,7 +264,7 @@ discard block | ||
| 264 | 264 | $placeholders = array(); | 
| 265 | 265 | $commands = $this->getCollection()->getCommands(); | 
| 266 | 266 | |
| 267 | - foreach($commands as $command) | |
| 267 | + foreach ($commands as $command) | |
| 268 | 268 |          { | 
| 269 | 269 | self::$counter++; | 
| 270 | 270 | |
| @@ -287,21 +287,21 @@ discard block | ||
| 287 | 287 | * @return string | 
| 288 | 288 | * @throws Mailcode_Exception | 
| 289 | 289 | */ | 
| 290 | - protected function restore(string $string, bool $partial=false, bool $highlighted=false) : string | |
| 290 | + protected function restore(string $string, bool $partial = false, bool $highlighted = false) : string | |
| 291 | 291 |      { | 
| 292 | - if(!$partial) | |
| 292 | + if (!$partial) | |
| 293 | 293 |          { | 
| 294 | 294 | $this->requireValidCollection(); | 
| 295 | 295 | } | 
| 296 | 296 | |
| 297 | 297 | $formatting = $this->createFormatting($string); | 
| 298 | 298 | |
| 299 | - if($partial) | |
| 299 | + if ($partial) | |
| 300 | 300 |          { | 
| 301 | 301 | $formatting->makePartial(); | 
| 302 | 302 | } | 
| 303 | 303 | |
| 304 | - if($highlighted) | |
| 304 | + if ($highlighted) | |
| 305 | 305 |          { | 
| 306 | 306 | $formatting->replaceWithHTMLHighlighting(); | 
| 307 | 307 | } | 
| @@ -397,7 +397,7 @@ discard block | ||
| 397 | 397 | */ | 
| 398 | 398 | public function getCollection() : Mailcode_Collection | 
| 399 | 399 |      { | 
| 400 | - if(isset($this->collection)) | |
| 400 | + if (isset($this->collection)) | |
| 401 | 401 |          { | 
| 402 | 402 | return $this->collection; | 
| 403 | 403 | } | 
| @@ -425,7 +425,7 @@ discard block | ||
| 425 | 425 | */ | 
| 426 | 426 | protected function requireValidCollection() : void | 
| 427 | 427 |      { | 
| 428 | - if($this->getCollection()->isValid()) | |
| 428 | + if ($this->getCollection()->isValid()) | |
| 429 | 429 |          { | 
| 430 | 430 | return; | 
| 431 | 431 | } |