@@ -22,17 +22,17 @@ |
||
| 22 | 22 | { |
| 23 | 23 | const REGEX_VARIABLE_NAME = '/\$\s*([A-Z0-9_]+)\s*\.\s*([A-Z0-9_]+)|\$\s*([A-Z0-9_]+)/six'; |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var Mailcode_Variables_Collection_Regular |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var Mailcode_Variables_Collection_Regular |
|
| 27 | + */ |
|
| 28 | 28 | protected $collection; |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Parses the specified string to find all variable names contained within, if any. |
|
| 32 | - * |
|
| 33 | - * @param string $subject |
|
| 34 | - * @return Mailcode_Variables_Collection_Regular |
|
| 35 | - */ |
|
| 30 | + /** |
|
| 31 | + * Parses the specified string to find all variable names contained within, if any. |
|
| 32 | + * |
|
| 33 | + * @param string $subject |
|
| 34 | + * @return Mailcode_Variables_Collection_Regular |
|
| 35 | + */ |
|
| 36 | 36 | public function parseString(string $subject) : Mailcode_Variables_Collection_Regular |
| 37 | 37 | { |
| 38 | 38 | $this->collection = new Mailcode_Variables_Collection_Regular(); |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | $matches = array(); |
| 41 | 41 | preg_match_all(self::REGEX_VARIABLE_NAME, $subject, $matches, PREG_PATTERN_ORDER); |
| 42 | 42 | |
| 43 | - if(!isset($matches[0]) || empty($matches[0])) |
|
| 43 | + if (!isset($matches[0]) || empty($matches[0])) |
|
| 44 | 44 | { |
| 45 | 45 | return $this->collection; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - foreach($matches[0] as $idx => $matchedText) |
|
| 48 | + foreach ($matches[0] as $idx => $matchedText) |
|
| 49 | 49 | { |
| 50 | - if(!empty($matches[3][$idx])) |
|
| 50 | + if (!empty($matches[3][$idx])) |
|
| 51 | 51 | { |
| 52 | 52 | $this->addSingle($matches[3][$idx], $matchedText); |
| 53 | 53 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | protected function addSingle(string $name, string $matchedText) : void |
| 64 | 64 | { |
| 65 | 65 | // ignore US style numbers like $451 |
| 66 | - if(is_numeric($name)) |
|
| 66 | + if (is_numeric($name)) |
|
| 67 | 67 | { |
| 68 | 68 | return; |
| 69 | 69 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | protected function addPathed(string $path, string $name, string $matchedText) : void |
| 75 | 75 | { |
| 76 | 76 | // ignore US style numbers like $45.12 |
| 77 | - if(is_numeric($path.'.'.$name)) |
|
| 77 | + if (is_numeric($path.'.'.$name)) |
|
| 78 | 78 | { |
| 79 | 79 | return; |
| 80 | 80 | } |
@@ -50,8 +50,7 @@ |
||
| 50 | 50 | if(!empty($matches[3][$idx])) |
| 51 | 51 | { |
| 52 | 52 | $this->addSingle($matches[3][$idx], $matchedText); |
| 53 | - } |
|
| 54 | - else |
|
| 53 | + } else |
|
| 55 | 54 | { |
| 56 | 55 | $this->addPathed($matches[1][$idx], $matches[2][$idx], $matchedText); |
| 57 | 56 | } |
@@ -26,51 +26,51 @@ 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()->parseString($string); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Retrieves the string parser instance used to detect commands. |
|
| 71 | - * |
|
| 72 | - * @return Mailcode_Parser |
|
| 73 | - */ |
|
| 69 | + /** |
|
| 70 | + * Retrieves the string parser instance used to detect commands. |
|
| 71 | + * |
|
| 72 | + * @return Mailcode_Parser |
|
| 73 | + */ |
|
| 74 | 74 | public function getParser() : Mailcode_Parser |
| 75 | 75 | { |
| 76 | 76 | if(!isset($this->parser)) |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | return $this->parser; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Retrieves the commands collection, which is used to |
|
| 86 | - * access information on the available commands. |
|
| 87 | - * |
|
| 88 | - * @return Mailcode_Commands |
|
| 89 | - */ |
|
| 84 | + /** |
|
| 85 | + * Retrieves the commands collection, which is used to |
|
| 86 | + * access information on the available commands. |
|
| 87 | + * |
|
| 88 | + * @return Mailcode_Commands |
|
| 89 | + */ |
|
| 90 | 90 | public function getCommands() : Mailcode_Commands |
| 91 | 91 | { |
| 92 | 92 | if(!isset($this->commands)) |
@@ -102,12 +102,12 @@ discard block |
||
| 102 | 102 | return $this->getParser()->createSafeguard($subject); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Attempts to find all variables in the target string. |
|
| 107 | - * |
|
| 108 | - * @param string $subject |
|
| 109 | - * @return Mailcode_Variables_Collection_Regular |
|
| 110 | - */ |
|
| 105 | + /** |
|
| 106 | + * Attempts to find all variables in the target string. |
|
| 107 | + * |
|
| 108 | + * @param string $subject |
|
| 109 | + * @return Mailcode_Variables_Collection_Regular |
|
| 110 | + */ |
|
| 111 | 111 | public function findVariables(string $subject) : Mailcode_Variables_Collection_Regular |
| 112 | 112 | { |
| 113 | 113 | return $this->createVariables()->parseString($subject); |
@@ -123,12 +123,12 @@ discard block |
||
| 123 | 123 | return $this->variables; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Creates the translator, which can be used to convert commands |
|
| 128 | - * to another supported syntax. |
|
| 129 | - * |
|
| 130 | - * @return Mailcode_Translator |
|
| 131 | - */ |
|
| 126 | + /** |
|
| 127 | + * Creates the translator, which can be used to convert commands |
|
| 128 | + * to another supported syntax. |
|
| 129 | + * |
|
| 130 | + * @return Mailcode_Translator |
|
| 131 | + */ |
|
| 132 | 132 | public function createTranslator() : Mailcode_Translator |
| 133 | 133 | { |
| 134 | 134 | if(!isset($this->translator)) |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function getParser() : Mailcode_Parser |
| 75 | 75 | { |
| 76 | - if(!isset($this->parser)) |
|
| 76 | + if (!isset($this->parser)) |
|
| 77 | 77 | { |
| 78 | 78 | $this->parser = new Mailcode_Parser($this); |
| 79 | 79 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function getCommands() : Mailcode_Commands |
| 91 | 91 | { |
| 92 | - if(!isset($this->commands)) |
|
| 92 | + if (!isset($this->commands)) |
|
| 93 | 93 | { |
| 94 | 94 | $this->commands = new Mailcode_Commands(); |
| 95 | 95 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | public function createVariables() : Mailcode_Variables |
| 117 | 117 | { |
| 118 | - if(!isset($this->variables)) |
|
| 118 | + if (!isset($this->variables)) |
|
| 119 | 119 | { |
| 120 | 120 | $this->variables = new Mailcode_Variables(); |
| 121 | 121 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function createTranslator() : Mailcode_Translator |
| 133 | 133 | { |
| 134 | - if(!isset($this->translator)) |
|
| 134 | + if (!isset($this->translator)) |
|
| 135 | 135 | { |
| 136 | 136 | $this->translator = new Mailcode_Translator(); |
| 137 | 137 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | $this->paramsString = trim($this->paramsString); |
| 26 | 26 | |
| 27 | 27 | // automatically quote the parameters, since comments don't require any. |
| 28 | - if(substr($this->paramsString, 0, 1) != '"') |
|
| 28 | + if (substr($this->paramsString, 0, 1) != '"') |
|
| 29 | 29 | { |
| 30 | 30 | $this->paramsString = '"'.$this->paramsString.'"'; |
| 31 | 31 | } |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | const ERROR_CANNOT_RETRIEVE_FIRST_ERROR = 52301; |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var Mailcode_Commands_Command[] |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * @var Mailcode_Commands_Command[] |
|
| 29 | + */ |
|
| 30 | 30 | protected $commands = array(); |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -34,17 +34,17 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | protected $errors = array(); |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var OperationResult|NULL |
|
| 39 | - */ |
|
| 37 | + /** |
|
| 38 | + * @var OperationResult|NULL |
|
| 39 | + */ |
|
| 40 | 40 | protected $validationResult; |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Adds a command to the collection. |
|
| 44 | - * |
|
| 45 | - * @param Mailcode_Commands_Command $command |
|
| 46 | - * @return Mailcode_Collection |
|
| 47 | - */ |
|
| 42 | + /** |
|
| 43 | + * Adds a command to the collection. |
|
| 44 | + * |
|
| 45 | + * @param Mailcode_Commands_Command $command |
|
| 46 | + * @return Mailcode_Collection |
|
| 47 | + */ |
|
| 48 | 48 | public function addCommand(Mailcode_Commands_Command $command) : Mailcode_Collection |
| 49 | 49 | { |
| 50 | 50 | $this->commands[] = $command; |
@@ -56,21 +56,21 @@ discard block |
||
| 56 | 56 | return $this; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Whether there are any commands in the collection. |
|
| 61 | - * |
|
| 62 | - * @return bool |
|
| 63 | - */ |
|
| 59 | + /** |
|
| 60 | + * Whether there are any commands in the collection. |
|
| 61 | + * |
|
| 62 | + * @return bool |
|
| 63 | + */ |
|
| 64 | 64 | public function hasCommands() : bool |
| 65 | 65 | { |
| 66 | 66 | return !empty($this->commands); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Counts the amount of commands in the collection. |
|
| 71 | - * |
|
| 72 | - * @return int |
|
| 73 | - */ |
|
| 69 | + /** |
|
| 70 | + * Counts the amount of commands in the collection. |
|
| 71 | + * |
|
| 72 | + * @return int |
|
| 73 | + */ |
|
| 74 | 74 | public function countCommands() : int |
| 75 | 75 | { |
| 76 | 76 | return count($this->commands); |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | $this->errors[] = new Mailcode_Collection_Error_Command($command); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @return Mailcode_Collection_Error[] |
|
| 95 | - */ |
|
| 93 | + /** |
|
| 94 | + * @return Mailcode_Collection_Error[] |
|
| 95 | + */ |
|
| 96 | 96 | public function getErrors() |
| 97 | 97 | { |
| 98 | 98 | $result = $this->getValidationResult(); |
@@ -134,25 +134,25 @@ discard block |
||
| 134 | 134 | return empty($errors); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Retrieves all commands that were detected, in the exact order |
|
| 139 | - * they were found. |
|
| 140 | - * |
|
| 141 | - * @return \Mailcode\Mailcode_Commands_Command[] |
|
| 142 | - */ |
|
| 137 | + /** |
|
| 138 | + * Retrieves all commands that were detected, in the exact order |
|
| 139 | + * they were found. |
|
| 140 | + * |
|
| 141 | + * @return \Mailcode\Mailcode_Commands_Command[] |
|
| 142 | + */ |
|
| 143 | 143 | public function getCommands() |
| 144 | 144 | { |
| 145 | - return $this->commands; |
|
| 145 | + return $this->commands; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Retrieves all unique commands by their matched |
|
| 150 | - * string hash: this ensures only commands that were |
|
| 151 | - * written the exact same way (including spacing) |
|
| 152 | - * are returned. |
|
| 153 | - * |
|
| 154 | - * @return \Mailcode\Mailcode_Commands_Command[] |
|
| 155 | - */ |
|
| 148 | + /** |
|
| 149 | + * Retrieves all unique commands by their matched |
|
| 150 | + * string hash: this ensures only commands that were |
|
| 151 | + * written the exact same way (including spacing) |
|
| 152 | + * are returned. |
|
| 153 | + * |
|
| 154 | + * @return \Mailcode\Mailcode_Commands_Command[] |
|
| 155 | + */ |
|
| 156 | 156 | public function getGroupedByHash() |
| 157 | 157 | { |
| 158 | 158 | $hashes = array(); |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | return array_values($hashes); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - /** |
|
| 174 | - * Adds several commands at once. |
|
| 175 | - * |
|
| 176 | - * @param Mailcode_Commands_Command[] $commands |
|
| 177 | - * @return Mailcode_Collection |
|
| 178 | - */ |
|
| 173 | + /** |
|
| 174 | + * Adds several commands at once. |
|
| 175 | + * |
|
| 176 | + * @param Mailcode_Commands_Command[] $commands |
|
| 177 | + * @return Mailcode_Collection |
|
| 178 | + */ |
|
| 179 | 179 | public function addCommands(array $commands) : Mailcode_Collection |
| 180 | 180 | { |
| 181 | 181 | foreach($commands as $command) |
@@ -234,11 +234,11 @@ discard block |
||
| 234 | 234 | return false; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * Retrieves only show variable commands in the collection, if any. |
|
| 239 | - * |
|
| 240 | - * @return \Mailcode\Mailcode_Commands_Command_ShowVariable[] |
|
| 241 | - */ |
|
| 237 | + /** |
|
| 238 | + * Retrieves only show variable commands in the collection, if any. |
|
| 239 | + * |
|
| 240 | + * @return \Mailcode\Mailcode_Commands_Command_ShowVariable[] |
|
| 241 | + */ |
|
| 242 | 242 | public function getShowVariableCommands() |
| 243 | 243 | { |
| 244 | 244 | $result = array(); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | $errors = $this->errors; |
| 101 | 101 | |
| 102 | - if(!$result->isValid()) |
|
| 102 | + if (!$result->isValid()) |
|
| 103 | 103 | { |
| 104 | 104 | $errors[] = new Mailcode_Collection_Error_Message( |
| 105 | 105 | '', |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | $errors = $this->getErrors(); |
| 117 | 117 | |
| 118 | - if(!empty($errors)) |
|
| 118 | + if (!empty($errors)) |
|
| 119 | 119 | { |
| 120 | 120 | return array_shift($errors); |
| 121 | 121 | } |
@@ -157,11 +157,11 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | $hashes = array(); |
| 159 | 159 | |
| 160 | - foreach($this->commands as $command) |
|
| 160 | + foreach ($this->commands as $command) |
|
| 161 | 161 | { |
| 162 | 162 | $hash = $command->getHash(); |
| 163 | 163 | |
| 164 | - if(!isset($hashes[$hash])) |
|
| 164 | + if (!isset($hashes[$hash])) |
|
| 165 | 165 | { |
| 166 | 166 | $hashes[$hash] = $command; |
| 167 | 167 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function addCommands(array $commands) : Mailcode_Collection |
| 180 | 180 | { |
| 181 | - foreach($commands as $command) |
|
| 181 | + foreach ($commands as $command) |
|
| 182 | 182 | { |
| 183 | 183 | $this->addCommand($command); |
| 184 | 184 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | { |
| 198 | 198 | $collection = new Mailcode_Variables_Collection_Regular(); |
| 199 | 199 | |
| 200 | - foreach($this->commands as $command) |
|
| 200 | + foreach ($this->commands as $command) |
|
| 201 | 201 | { |
| 202 | 202 | $collection->mergeWith($command->getVariables()); |
| 203 | 203 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | public function getValidationResult() : OperationResult |
| 209 | 209 | { |
| 210 | - if($this->validationResult instanceof OperationResult) |
|
| 210 | + if ($this->validationResult instanceof OperationResult) |
|
| 211 | 211 | { |
| 212 | 212 | return $this->validationResult; |
| 213 | 213 | } |
@@ -223,9 +223,9 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | $errors = $this->getErrors(); |
| 225 | 225 | |
| 226 | - foreach($errors as $error) |
|
| 226 | + foreach ($errors as $error) |
|
| 227 | 227 | { |
| 228 | - if($error->getCode() === $code) |
|
| 228 | + if ($error->getCode() === $code) |
|
| 229 | 229 | { |
| 230 | 230 | return true; |
| 231 | 231 | } |
@@ -243,9 +243,9 @@ discard block |
||
| 243 | 243 | { |
| 244 | 244 | $result = array(); |
| 245 | 245 | |
| 246 | - foreach($this->commands as $command) |
|
| 246 | + foreach ($this->commands as $command) |
|
| 247 | 247 | { |
| 248 | - if($command instanceof Mailcode_Commands_Command_ShowVariable) |
|
| 248 | + if ($command instanceof Mailcode_Commands_Command_ShowVariable) |
|
| 249 | 249 | { |
| 250 | 250 | $result[] = $command; |
| 251 | 251 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | { |
| 259 | 259 | $commands = $this->getCommands(); |
| 260 | 260 | |
| 261 | - if(!empty($commands)) |
|
| 261 | + if (!empty($commands)) |
|
| 262 | 262 | { |
| 263 | 263 | return array_shift($commands); |
| 264 | 264 | } |
@@ -157,7 +157,8 @@ discard block |
||
| 157 | 157 | throw self::_exceptionUnexpectedType('Comment', $cmd); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public static function else() : Mailcode_Commands_Command_Else |
|
| 160 | + public static function else { |
|
| 161 | + () : Mailcode_Commands_Command_Else |
|
| 161 | 162 | { |
| 162 | 163 | $cmd = Mailcode::create()->getCommands()->createCommand( |
| 163 | 164 | 'Else', |
@@ -165,6 +166,7 @@ discard block |
||
| 165 | 166 | '', |
| 166 | 167 | '{else}' |
| 167 | 168 | ); |
| 169 | + } |
|
| 168 | 170 | |
| 169 | 171 | self::_checkCommand($cmd); |
| 170 | 172 | |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | const ERROR_UNEXPECTED_COMMAND_TYPE = 50002; |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var Mailcode_Renderer |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * @var Mailcode_Renderer |
|
| 29 | + */ |
|
| 30 | 30 | protected static $renderer; |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Creates a ShowVariable command. |
|
| 34 | - * |
|
| 35 | - * @param string $variableName A variable name, with or without the $ sign prepended. |
|
| 36 | - * @return Mailcode_Commands_Command_ShowVariable |
|
| 37 | - */ |
|
| 32 | + /** |
|
| 33 | + * Creates a ShowVariable command. |
|
| 34 | + * |
|
| 35 | + * @param string $variableName A variable name, with or without the $ sign prepended. |
|
| 36 | + * @return Mailcode_Commands_Command_ShowVariable |
|
| 37 | + */ |
|
| 38 | 38 | public static function showVar(string $variableName) : Mailcode_Commands_Command_ShowVariable |
| 39 | 39 | { |
| 40 | 40 | $variableName = self::_filterVariableName($variableName); |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Creates a ShowSnippet command. |
|
| 104 | - * |
|
| 105 | - * @param string $snippetName A snippet name, with or without the $ sign prepended. |
|
| 106 | - * @return Mailcode_Commands_Command_ShowSnippet |
|
| 107 | - */ |
|
| 102 | + /** |
|
| 103 | + * Creates a ShowSnippet command. |
|
| 104 | + * |
|
| 105 | + * @param string $snippetName A snippet name, with or without the $ sign prepended. |
|
| 106 | + * @return Mailcode_Commands_Command_ShowSnippet |
|
| 107 | + */ |
|
| 108 | 108 | public static function showSnippet(string $snippetName) : Mailcode_Commands_Command_ShowSnippet |
| 109 | 109 | { |
| 110 | 110 | $snippetName = self::_filterVariableName($snippetName); |
@@ -126,17 +126,17 @@ discard block |
||
| 126 | 126 | throw self::_exceptionUnexpectedType('ShowSnippet', $cmd); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Creates a SetVariable command. |
|
| 131 | - * |
|
| 132 | - * @param string $variableName A variable name, with or without the $ sign prepended. |
|
| 133 | - * @param string $value |
|
| 134 | - * @param bool $quoteValue Whether to treat the value as a string literal, and add quotes to it. |
|
| 135 | - * @return Mailcode_Commands_Command_SetVariable |
|
| 136 | - * @throws Mailcode_Factory_Exception |
|
| 137 | - * |
|
| 138 | - * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
|
| 139 | - */ |
|
| 129 | + /** |
|
| 130 | + * Creates a SetVariable command. |
|
| 131 | + * |
|
| 132 | + * @param string $variableName A variable name, with or without the $ sign prepended. |
|
| 133 | + * @param string $value |
|
| 134 | + * @param bool $quoteValue Whether to treat the value as a string literal, and add quotes to it. |
|
| 135 | + * @return Mailcode_Commands_Command_SetVariable |
|
| 136 | + * @throws Mailcode_Factory_Exception |
|
| 137 | + * |
|
| 138 | + * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
|
| 139 | + */ |
|
| 140 | 140 | public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable |
| 141 | 141 | { |
| 142 | 142 | $variableName = self::_filterVariableName($variableName); |
@@ -165,14 +165,14 @@ discard block |
||
| 165 | 165 | throw self::_exceptionUnexpectedType('SetVariable', $cmd); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Like setVar(), but treats the value as a string literal |
|
| 170 | - * and automatically adds quotes to it. |
|
| 171 | - * |
|
| 172 | - * @param string $variableName |
|
| 173 | - * @param string $value |
|
| 174 | - * @return Mailcode_Commands_Command_SetVariable |
|
| 175 | - */ |
|
| 168 | + /** |
|
| 169 | + * Like setVar(), but treats the value as a string literal |
|
| 170 | + * and automatically adds quotes to it. |
|
| 171 | + * |
|
| 172 | + * @param string $variableName |
|
| 173 | + * @param string $value |
|
| 174 | + * @return Mailcode_Commands_Command_SetVariable |
|
| 175 | + */ |
|
| 176 | 176 | public static function setVarString(string $variableName, string $value) : Mailcode_Commands_Command_SetVariable |
| 177 | 177 | { |
| 178 | 178 | return self::setVar($variableName, $value, true); |
@@ -504,12 +504,12 @@ discard block |
||
| 504 | 504 | return '$'.ltrim($name, '$'); |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - /** |
|
| 508 | - * Quotes a string literal: adds the quotes, and escapes any quotes already present in it. |
|
| 509 | - * |
|
| 510 | - * @param string $string |
|
| 511 | - * @return string |
|
| 512 | - */ |
|
| 507 | + /** |
|
| 508 | + * Quotes a string literal: adds the quotes, and escapes any quotes already present in it. |
|
| 509 | + * |
|
| 510 | + * @param string $string |
|
| 511 | + * @return string |
|
| 512 | + */ |
|
| 513 | 513 | protected static function _quoteString(string $string) : string |
| 514 | 514 | { |
| 515 | 515 | return '"'.str_replace('"', '\"', $string).'"'; |
@@ -542,34 +542,34 @@ discard block |
||
| 542 | 542 | ); |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | - /** |
|
| 546 | - * Creates a renderer instance, which can be used to easily |
|
| 547 | - * create and convert commands to strings. |
|
| 548 | - * |
|
| 549 | - * @return Mailcode_Renderer |
|
| 550 | - */ |
|
| 545 | + /** |
|
| 546 | + * Creates a renderer instance, which can be used to easily |
|
| 547 | + * create and convert commands to strings. |
|
| 548 | + * |
|
| 549 | + * @return Mailcode_Renderer |
|
| 550 | + */ |
|
| 551 | 551 | public static function createRenderer() : Mailcode_Renderer |
| 552 | 552 | { |
| 553 | 553 | return new Mailcode_Renderer(); |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - /** |
|
| 557 | - * Creates a printer instance, which works like the renderer, |
|
| 558 | - * but outputs the generated strings to standard output. |
|
| 559 | - * |
|
| 560 | - * @return Mailcode_Printer |
|
| 561 | - */ |
|
| 556 | + /** |
|
| 557 | + * Creates a printer instance, which works like the renderer, |
|
| 558 | + * but outputs the generated strings to standard output. |
|
| 559 | + * |
|
| 560 | + * @return Mailcode_Printer |
|
| 561 | + */ |
|
| 562 | 562 | public static function createPrinter() : Mailcode_Printer |
| 563 | 563 | { |
| 564 | 564 | return new Mailcode_Printer(); |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - /** |
|
| 568 | - * Gets/creates the global instance of the date format info |
|
| 569 | - * class, used to handle date formatting aspects. |
|
| 570 | - * |
|
| 571 | - * @return Mailcode_Date_FormatInfo |
|
| 572 | - */ |
|
| 567 | + /** |
|
| 568 | + * Gets/creates the global instance of the date format info |
|
| 569 | + * class, used to handle date formatting aspects. |
|
| 570 | + * |
|
| 571 | + * @return Mailcode_Date_FormatInfo |
|
| 572 | + */ |
|
| 573 | 573 | public static function createDateInfo() : Mailcode_Date_FormatInfo |
| 574 | 574 | { |
| 575 | 575 | return Mailcode_Date_FormatInfo::getInstance(); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | self::_checkCommand($cmd); |
| 50 | 50 | |
| 51 | - if($cmd instanceof Mailcode_Commands_Command_ShowVariable) |
|
| 51 | + if ($cmd instanceof Mailcode_Commands_Command_ShowVariable) |
|
| 52 | 52 | { |
| 53 | 53 | return $cmd; |
| 54 | 54 | } |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | * @param string $formatString A date format string, or empty string for default. |
| 65 | 65 | * @return Mailcode_Commands_Command_ShowDate |
| 66 | 66 | */ |
| 67 | - public static function showDate(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowDate |
|
| 67 | + public static function showDate(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowDate |
|
| 68 | 68 | { |
| 69 | 69 | $variableName = self::_filterVariableName($variableName); |
| 70 | 70 | |
| 71 | 71 | $format = ''; |
| 72 | - if(!empty($formatString)) |
|
| 72 | + if (!empty($formatString)) |
|
| 73 | 73 | { |
| 74 | 74 | $format = sprintf( |
| 75 | 75 | ' "%s"', |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | self::_checkCommand($cmd); |
| 92 | 92 | |
| 93 | - if($cmd instanceof Mailcode_Commands_Command_ShowDate) |
|
| 93 | + if ($cmd instanceof Mailcode_Commands_Command_ShowDate) |
|
| 94 | 94 | { |
| 95 | 95 | return $cmd; |
| 96 | 96 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | self::_checkCommand($cmd); |
| 120 | 120 | |
| 121 | - if($cmd instanceof Mailcode_Commands_Command_ShowSnippet) |
|
| 121 | + if ($cmd instanceof Mailcode_Commands_Command_ShowSnippet) |
|
| 122 | 122 | { |
| 123 | 123 | return $cmd; |
| 124 | 124 | } |
@@ -137,11 +137,11 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
| 139 | 139 | */ |
| 140 | - public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable |
|
| 140 | + public static function setVar(string $variableName, string $value, bool $quoteValue = true) : Mailcode_Commands_Command_SetVariable |
|
| 141 | 141 | { |
| 142 | 142 | $variableName = self::_filterVariableName($variableName); |
| 143 | 143 | |
| 144 | - if($quoteValue) |
|
| 144 | + if ($quoteValue) |
|
| 145 | 145 | { |
| 146 | 146 | $value = self::_quoteString($value); |
| 147 | 147 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | self::_checkCommand($cmd); |
| 159 | 159 | |
| 160 | - if($cmd instanceof Mailcode_Commands_Command_SetVariable) |
|
| 160 | + if ($cmd instanceof Mailcode_Commands_Command_SetVariable) |
|
| 161 | 161 | { |
| 162 | 162 | return $cmd; |
| 163 | 163 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | self::_checkCommand($cmd); |
| 194 | 194 | |
| 195 | - if($cmd instanceof Mailcode_Commands_Command_Comment) |
|
| 195 | + if ($cmd instanceof Mailcode_Commands_Command_Comment) |
|
| 196 | 196 | { |
| 197 | 197 | return $cmd; |
| 198 | 198 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | self::_checkCommand($cmd); |
| 213 | 213 | |
| 214 | - if($cmd instanceof Mailcode_Commands_Command_Else) |
|
| 214 | + if ($cmd instanceof Mailcode_Commands_Command_Else) |
|
| 215 | 215 | { |
| 216 | 216 | return $cmd; |
| 217 | 217 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | self::_checkCommand($cmd); |
| 232 | 232 | |
| 233 | - if($cmd instanceof Mailcode_Commands_Command_End) |
|
| 233 | + if ($cmd instanceof Mailcode_Commands_Command_End) |
|
| 234 | 234 | { |
| 235 | 235 | return $cmd; |
| 236 | 236 | } |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | throw self::_exceptionUnexpectedType('End', $cmd); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - protected static function _buildIf(string $ifType, string $params, string $type='') : Mailcode_Commands_IfBase |
|
| 241 | + protected static function _buildIf(string $ifType, string $params, string $type = '') : Mailcode_Commands_IfBase |
|
| 242 | 242 | { |
| 243 | 243 | $stringType = $type; |
| 244 | 244 | |
| 245 | - if(!empty($type)) |
|
| 245 | + if (!empty($type)) |
|
| 246 | 246 | { |
| 247 | 247 | $stringType = ' '.$type; |
| 248 | 248 | } |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | self::_checkCommand($command); |
| 263 | 263 | |
| 264 | - if($command instanceof Mailcode_Commands_IfBase) |
|
| 264 | + if ($command instanceof Mailcode_Commands_IfBase) |
|
| 265 | 265 | { |
| 266 | 266 | return $command; |
| 267 | 267 | } |
@@ -269,9 +269,9 @@ discard block |
||
| 269 | 269 | throw self::_exceptionUnexpectedType('IfBase', $command); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - protected static function _buildIfVar(string $ifType, string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_IfBase |
|
| 272 | + protected static function _buildIfVar(string $ifType, string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_IfBase |
|
| 273 | 273 | { |
| 274 | - if($quoteValue) |
|
| 274 | + if ($quoteValue) |
|
| 275 | 275 | { |
| 276 | 276 | $value = self::_quoteString($value); |
| 277 | 277 | } |
@@ -286,11 +286,11 @@ discard block |
||
| 286 | 286 | return self::_buildIf($ifType, $condition, 'variable'); |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - public static function if(string $condition, string $type='') : Mailcode_Commands_Command_If |
|
| 289 | + public static function if (string $condition, string $type = '') : Mailcode_Commands_Command_If |
|
| 290 | 290 | { |
| 291 | 291 | $command = self::_buildIf('If', $condition, $type); |
| 292 | 292 | |
| 293 | - if($command instanceof Mailcode_Commands_Command_If) |
|
| 293 | + if ($command instanceof Mailcode_Commands_Command_If) |
|
| 294 | 294 | { |
| 295 | 295 | return $command; |
| 296 | 296 | } |
@@ -298,11 +298,11 @@ discard block |
||
| 298 | 298 | throw self::_exceptionUnexpectedType('If', $command); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable |
|
| 301 | + public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable |
|
| 302 | 302 | { |
| 303 | 303 | $command = self::_buildIfVar('If', $variable, $operand, $value, $quoteValue); |
| 304 | 304 | |
| 305 | - if($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 305 | + if ($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 306 | 306 | { |
| 307 | 307 | return $command; |
| 308 | 308 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | { |
| 315 | 315 | $command = self::_buildIfVar('If', $variable, $operand, $value, true); |
| 316 | 316 | |
| 317 | - if($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 317 | + if ($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 318 | 318 | { |
| 319 | 319 | return $command; |
| 320 | 320 | } |
@@ -322,11 +322,11 @@ discard block |
||
| 322 | 322 | throw self::_exceptionUnexpectedType('IfVarString', $command); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - public static function ifVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable |
|
| 325 | + public static function ifVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable |
|
| 326 | 326 | { |
| 327 | 327 | $command = self::_buildIfVar('If', $variable, '==', $value, $quoteValue); |
| 328 | 328 | |
| 329 | - if($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 329 | + if ($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 330 | 330 | { |
| 331 | 331 | return $command; |
| 332 | 332 | } |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | { |
| 339 | 339 | $command = self::_buildIfVar('If', $variable, '==', $value, true); |
| 340 | 340 | |
| 341 | - if($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 341 | + if ($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 342 | 342 | { |
| 343 | 343 | return $command; |
| 344 | 344 | } |
@@ -346,11 +346,11 @@ discard block |
||
| 346 | 346 | throw self::_exceptionUnexpectedType('IfarEqualsString', $command); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable |
|
| 349 | + public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable |
|
| 350 | 350 | { |
| 351 | 351 | $command = self::_buildIfVar('If', $variable, '!=', $value, $quoteValue); |
| 352 | 352 | |
| 353 | - if($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 353 | + if ($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 354 | 354 | { |
| 355 | 355 | return $command; |
| 356 | 356 | } |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | { |
| 363 | 363 | $command = self::_buildIfVar('If', $variable, '!=', $value, true); |
| 364 | 364 | |
| 365 | - if($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 365 | + if ($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 366 | 366 | { |
| 367 | 367 | return $command; |
| 368 | 368 | } |
@@ -370,11 +370,11 @@ discard block |
||
| 370 | 370 | throw self::_exceptionUnexpectedType('IfVarNotEqualsString', $command); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - public static function elseIf(string $condition, string $type='') : Mailcode_Commands_Command_ElseIf |
|
| 373 | + public static function elseIf (string $condition, string $type = '') : Mailcode_Commands_Command_ElseIf |
|
| 374 | 374 | { |
| 375 | 375 | $command = self::_buildIf('ElseIf', $condition, $type); |
| 376 | 376 | |
| 377 | - if($command instanceof Mailcode_Commands_Command_ElseIf) |
|
| 377 | + if ($command instanceof Mailcode_Commands_Command_ElseIf) |
|
| 378 | 378 | { |
| 379 | 379 | return $command; |
| 380 | 380 | } |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | throw self::_exceptionUnexpectedType('ElseIf', $command); |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable |
|
| 385 | + public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable |
|
| 386 | 386 | { |
| 387 | 387 | $command = self::_buildIfVar('ElseIf', $variable, $operand, $value, $quoteValue); |
| 388 | 388 | |
| 389 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 389 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 390 | 390 | { |
| 391 | 391 | return $command; |
| 392 | 392 | } |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | { |
| 399 | 399 | $command = self::_buildIfVar('ElseIf', $variable, $operand, $value, true); |
| 400 | 400 | |
| 401 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 401 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 402 | 402 | { |
| 403 | 403 | return $command; |
| 404 | 404 | } |
@@ -406,11 +406,11 @@ discard block |
||
| 406 | 406 | throw self::_exceptionUnexpectedType('ElseIfVarString', $command); |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable |
|
| 409 | + public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable |
|
| 410 | 410 | { |
| 411 | 411 | $command = self::_buildIfVar('ElseIf', $variable, '==', $value, $quoteValue); |
| 412 | 412 | |
| 413 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 413 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 414 | 414 | { |
| 415 | 415 | return $command; |
| 416 | 416 | } |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | { |
| 423 | 423 | $command = self::_buildIfVar('ElseIf', $variable, '==', $value, true); |
| 424 | 424 | |
| 425 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 425 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 426 | 426 | { |
| 427 | 427 | return $command; |
| 428 | 428 | } |
@@ -430,11 +430,11 @@ discard block |
||
| 430 | 430 | throw self::_exceptionUnexpectedType('ElseIfVarEqualsString', $command); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable |
|
| 433 | + public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable |
|
| 434 | 434 | { |
| 435 | 435 | $command = self::_buildIfVar('ElseIf', $variable, '!=', $value, $quoteValue); |
| 436 | 436 | |
| 437 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 437 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 438 | 438 | { |
| 439 | 439 | return $command; |
| 440 | 440 | } |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | { |
| 447 | 447 | $command = self::_buildIfVar('ElseIf', $variable, '!=', $value, true); |
| 448 | 448 | |
| 449 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 449 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 450 | 450 | { |
| 451 | 451 | return $command; |
| 452 | 452 | } |
@@ -454,11 +454,11 @@ discard block |
||
| 454 | 454 | throw self::_exceptionUnexpectedType('ElseIfVarNotEqualsString', $command); |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - public static function ifContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains |
|
| 457 | + public static function ifContains(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_Contains |
|
| 458 | 458 | { |
| 459 | 459 | $command = self::_buildIfContains('If', $variable, $search, $caseInsensitive); |
| 460 | 460 | |
| 461 | - if($command instanceof Mailcode_Commands_Command_If_Contains) |
|
| 461 | + if ($command instanceof Mailcode_Commands_Command_If_Contains) |
|
| 462 | 462 | { |
| 463 | 463 | return $command; |
| 464 | 464 | } |
@@ -466,11 +466,11 @@ discard block |
||
| 466 | 466 | throw self::_exceptionUnexpectedType('ElseIfContains', $command); |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - public static function elseIfContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains |
|
| 469 | + public static function elseIfContains(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_Contains |
|
| 470 | 470 | { |
| 471 | 471 | $command = self::_buildIfContains('ElseIf', $variable, $search, $caseInsensitive); |
| 472 | 472 | |
| 473 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Contains) |
|
| 473 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Contains) |
|
| 474 | 474 | { |
| 475 | 475 | return $command; |
| 476 | 476 | } |
@@ -478,11 +478,11 @@ discard block |
||
| 478 | 478 | throw self::_exceptionUnexpectedType('ElseIfContains', $command); |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - protected static function _buildIfContains(string $ifType, string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_IfBase |
|
| 481 | + protected static function _buildIfContains(string $ifType, string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_IfBase |
|
| 482 | 482 | { |
| 483 | 483 | $keyword = ' '; |
| 484 | 484 | |
| 485 | - if($caseInsensitive) |
|
| 485 | + if ($caseInsensitive) |
|
| 486 | 486 | { |
| 487 | 487 | $keyword = ' insensitive: '; |
| 488 | 488 | } |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | |
| 518 | 518 | protected static function _checkCommand(Mailcode_Commands_Command $command) : void |
| 519 | 519 | { |
| 520 | - if($command->isValid()) |
|
| 520 | + if ($command->isValid()) |
|
| 521 | 521 | { |
| 522 | 522 | return; |
| 523 | 523 | } |
@@ -20,13 +20,13 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | abstract class Mailcode_Translator_Syntax_ApacheVelocity extends Mailcode_Translator_Command |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * Filters the string for use in an Apache Velocity (Java) |
|
| 25 | - * regex string: escapes all special characters. |
|
| 26 | - * |
|
| 27 | - * @param string $string |
|
| 28 | - * @return string |
|
| 29 | - */ |
|
| 23 | + /** |
|
| 24 | + * Filters the string for use in an Apache Velocity (Java) |
|
| 25 | + * regex string: escapes all special characters. |
|
| 26 | + * |
|
| 27 | + * @param string $string |
|
| 28 | + * @return string |
|
| 29 | + */ |
|
| 30 | 30 | protected function filterRegexString(string $string) : string |
| 31 | 31 | { |
| 32 | 32 | $escape = array( |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | ')' |
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | - foreach($escape as $char) |
|
| 51 | + foreach ($escape as $char) |
|
| 52 | 52 | { |
| 53 | 53 | $string = str_replace($char, '\\'.$char, $string); |
| 54 | 54 | } |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | public function translate(Mailcode_Commands_Command_If $command): string |
| 24 | 24 | { |
| 25 | - if($command instanceof Mailcode_Commands_Command_If_Command) |
|
| 25 | + if ($command instanceof Mailcode_Commands_Command_If_Command) |
|
| 26 | 26 | { |
| 27 | 27 | return $this->translateCommand($command); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - if($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 30 | + if ($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 31 | 31 | { |
| 32 | 32 | return $this->translateVariable($command); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if($command instanceof Mailcode_Commands_Command_If_Contains) |
|
| 35 | + if ($command instanceof Mailcode_Commands_Command_If_Contains) |
|
| 36 | 36 | { |
| 37 | 37 | return $this->translateContains($command); |
| 38 | 38 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | $params = $command->getParams(); |
| 46 | 46 | |
| 47 | - if(!$params) |
|
| 47 | + if (!$params) |
|
| 48 | 48 | { |
| 49 | 49 | return ''; |
| 50 | 50 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | protected function translateContains(Mailcode_Commands_Command_If_Contains $command) : string |
| 69 | 69 | { |
| 70 | 70 | $opts = 's'; |
| 71 | - if($command->isCaseInsensitive()) |
|
| 71 | + if ($command->isCaseInsensitive()) |
|
| 72 | 72 | { |
| 73 | 73 | $opts = 'is'; |
| 74 | 74 | } |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | public function translate(Mailcode_Commands_Command_ElseIf $command): string |
| 24 | 24 | { |
| 25 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Command) |
|
| 25 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Command) |
|
| 26 | 26 | { |
| 27 | 27 | return $this->translateCommand($command); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 30 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 31 | 31 | { |
| 32 | 32 | return $this->translateVariable($command); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Contains) |
|
| 35 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Contains) |
|
| 36 | 36 | { |
| 37 | 37 | return $this->translateContains($command); |
| 38 | 38 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | $params = $command->getParams(); |
| 46 | 46 | |
| 47 | - if(!$params) |
|
| 47 | + if (!$params) |
|
| 48 | 48 | { |
| 49 | 49 | return ''; |
| 50 | 50 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | protected function translateContains(Mailcode_Commands_Command_ElseIf_Contains $command) : string |
| 69 | 69 | { |
| 70 | 70 | $opts = 's'; |
| 71 | - if($command->isCaseInsensitive()) |
|
| 71 | + if ($command->isCaseInsensitive()) |
|
| 72 | 72 | { |
| 73 | 73 | $opts = 'is'; |
| 74 | 74 | } |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | const ERROR_UNKNOWN_COMMAND_TYPE = 50401; |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 26 | + /** |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | 29 | protected $typeID; |
| 30 | 30 | |
| 31 | 31 | public function __construct(string $typeID) |
@@ -33,22 +33,22 @@ discard block |
||
| 33 | 33 | $this->typeID = $typeID; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Retrieves the syntax' type ID, e.g. "ApacheVelocity". |
|
| 38 | - * @return string |
|
| 39 | - */ |
|
| 36 | + /** |
|
| 37 | + * Retrieves the syntax' type ID, e.g. "ApacheVelocity". |
|
| 38 | + * @return string |
|
| 39 | + */ |
|
| 40 | 40 | public function getTypeID() : string |
| 41 | 41 | { |
| 42 | 42 | return $this->typeID; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Translates a single command to the target syntax. |
|
| 47 | - * |
|
| 48 | - * @param Mailcode_Commands_Command $command |
|
| 49 | - * @throws Mailcode_Translator_Exception |
|
| 50 | - * @return string |
|
| 51 | - */ |
|
| 45 | + /** |
|
| 46 | + * Translates a single command to the target syntax. |
|
| 47 | + * |
|
| 48 | + * @param Mailcode_Commands_Command $command |
|
| 49 | + * @throws Mailcode_Translator_Exception |
|
| 50 | + * @return string |
|
| 51 | + */ |
|
| 52 | 52 | public function translateCommand(Mailcode_Commands_Command $command) : string |
| 53 | 53 | { |
| 54 | 54 | $translator = $this->createTranslator($command); |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | return $translator; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Translates all safeguarded commands in the subject string to the |
|
| 86 | - * target syntax in one go. |
|
| 87 | - * |
|
| 88 | - * @param Mailcode_Parser_Safeguard $safeguard |
|
| 89 | - * @return string |
|
| 90 | - */ |
|
| 84 | + /** |
|
| 85 | + * Translates all safeguarded commands in the subject string to the |
|
| 86 | + * target syntax in one go. |
|
| 87 | + * |
|
| 88 | + * @param Mailcode_Parser_Safeguard $safeguard |
|
| 89 | + * @return string |
|
| 90 | + */ |
|
| 91 | 91 | public function translateSafeguard(Mailcode_Parser_Safeguard $safeguard) : string |
| 92 | 92 | { |
| 93 | 93 | $subject = $safeguard->makeSafe(); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $command->getID() |
| 65 | 65 | ); |
| 66 | 66 | |
| 67 | - if(!class_exists($class)) |
|
| 67 | + if (!class_exists($class)) |
|
| 68 | 68 | { |
| 69 | 69 | throw new Mailcode_Translator_Exception( |
| 70 | 70 | sprintf('Unknown command %s in translator', $command->getID()), |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | $subject = $safeguard->makeSafe(); |
| 94 | 94 | |
| 95 | - if(!$safeguard->hasPlaceholders()) |
|
| 95 | + if (!$safeguard->hasPlaceholders()) |
|
| 96 | 96 | { |
| 97 | 97 | return $subject; |
| 98 | 98 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | $replaces = array(); |
| 103 | 103 | |
| 104 | - foreach($placeholders as $placeholder) |
|
| 104 | + foreach ($placeholders as $placeholder) |
|
| 105 | 105 | { |
| 106 | 106 | $replaces[$placeholder->getReplacementText()] = $this->translateCommand($placeholder->getCommand()); |
| 107 | 107 | } |