@@ -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); |
@@ -50,17 +50,17 @@ discard block |
||
| 50 | 50 | return $cmd; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Creates a SetVariable command. |
|
| 55 | - * |
|
| 56 | - * @param string $variableName A variable name, with or without the $ sign prepended. |
|
| 57 | - * @param string $value |
|
| 58 | - * @param bool $quoteValue Whether to treat the value as a string literal, and add quotes to it. |
|
| 59 | - * @return Mailcode_Commands_Command_SetVariable |
|
| 60 | - * @throws Mailcode_Factory_Exception |
|
| 61 | - * |
|
| 62 | - * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
|
| 63 | - */ |
|
| 53 | + /** |
|
| 54 | + * Creates a SetVariable command. |
|
| 55 | + * |
|
| 56 | + * @param string $variableName A variable name, with or without the $ sign prepended. |
|
| 57 | + * @param string $value |
|
| 58 | + * @param bool $quoteValue Whether to treat the value as a string literal, and add quotes to it. |
|
| 59 | + * @return Mailcode_Commands_Command_SetVariable |
|
| 60 | + * @throws Mailcode_Factory_Exception |
|
| 61 | + * |
|
| 62 | + * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
|
| 63 | + */ |
|
| 64 | 64 | public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable |
| 65 | 65 | { |
| 66 | 66 | $variableName = self::_filterVariableName($variableName); |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | return $cmd; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Like setVar(), but treats the value as a string literal |
|
| 88 | - * and automatically adds quotes to it. |
|
| 89 | - * |
|
| 90 | - * @param string $variableName |
|
| 91 | - * @param string $value |
|
| 92 | - * @return Mailcode_Commands_Command_SetVariable |
|
| 93 | - */ |
|
| 86 | + /** |
|
| 87 | + * Like setVar(), but treats the value as a string literal |
|
| 88 | + * and automatically adds quotes to it. |
|
| 89 | + * |
|
| 90 | + * @param string $variableName |
|
| 91 | + * @param string $value |
|
| 92 | + * @return Mailcode_Commands_Command_SetVariable |
|
| 93 | + */ |
|
| 94 | 94 | public static function setVarString(string $variableName, string $value) : Mailcode_Commands_Command_SetVariable |
| 95 | 95 | { |
| 96 | 96 | return self::setVar($variableName, $value, true); |
@@ -355,12 +355,12 @@ discard block |
||
| 355 | 355 | return '$'.ltrim($name, '$'); |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - /** |
|
| 359 | - * Quotes a string literal: adds the quotes, and escapes any quotes already present in it. |
|
| 360 | - * |
|
| 361 | - * @param string $string |
|
| 362 | - * @return string |
|
| 363 | - */ |
|
| 358 | + /** |
|
| 359 | + * Quotes a string literal: adds the quotes, and escapes any quotes already present in it. |
|
| 360 | + * |
|
| 361 | + * @param string $string |
|
| 362 | + * @return string |
|
| 363 | + */ |
|
| 364 | 364 | protected static function _quoteString(string $string) : string |
| 365 | 365 | { |
| 366 | 366 | return '"'.str_replace('"', '\"', $string).'"'; |
@@ -393,23 +393,23 @@ discard block |
||
| 393 | 393 | ); |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - /** |
|
| 397 | - * Creates a renderer instance, which can be used to easily |
|
| 398 | - * create and convert commands to strings. |
|
| 399 | - * |
|
| 400 | - * @return Mailcode_Renderer |
|
| 401 | - */ |
|
| 396 | + /** |
|
| 397 | + * Creates a renderer instance, which can be used to easily |
|
| 398 | + * create and convert commands to strings. |
|
| 399 | + * |
|
| 400 | + * @return Mailcode_Renderer |
|
| 401 | + */ |
|
| 402 | 402 | public static function createRenderer() : Mailcode_Renderer |
| 403 | 403 | { |
| 404 | 404 | return new Mailcode_Renderer(); |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - /** |
|
| 408 | - * Creates a printer instance, which works like the renderer, |
|
| 409 | - * but outputs the generated strings to standard output. |
|
| 410 | - * |
|
| 411 | - * @return Mailcode_Printer |
|
| 412 | - */ |
|
| 407 | + /** |
|
| 408 | + * Creates a printer instance, which works like the renderer, |
|
| 409 | + * but outputs the generated strings to standard output. |
|
| 410 | + * |
|
| 411 | + * @return Mailcode_Printer |
|
| 412 | + */ |
|
| 413 | 413 | public static function createPrinter() : Mailcode_Printer |
| 414 | 414 | { |
| 415 | 415 | return new Mailcode_Printer(); |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
| 63 | 63 | */ |
| 64 | - public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable |
|
| 64 | + public static function setVar(string $variableName, string $value, bool $quoteValue = true) : Mailcode_Commands_Command_SetVariable |
|
| 65 | 65 | { |
| 66 | 66 | $variableName = self::_filterVariableName($variableName); |
| 67 | 67 | |
| 68 | - if($quoteValue) |
|
| 68 | + if ($quoteValue) |
|
| 69 | 69 | { |
| 70 | 70 | $value = self::_quoteString($value); |
| 71 | 71 | } |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | return $cmd; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - protected static function _buildIf(string $cmd, string $condition, string $type='') : Mailcode_Commands_Command |
|
| 141 | + protected static function _buildIf(string $cmd, string $condition, string $type = '') : Mailcode_Commands_Command |
|
| 142 | 142 | { |
| 143 | 143 | $stringType = $type; |
| 144 | 144 | |
| 145 | - if(!empty($type)) |
|
| 145 | + if (!empty($type)) |
|
| 146 | 146 | { |
| 147 | 147 | $stringType = ' '.$type; |
| 148 | 148 | } |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | return $cmd; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - protected static function _buildIfVar(string $cmd, string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command |
|
| 168 | + protected static function _buildIfVar(string $cmd, string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command |
|
| 169 | 169 | { |
| 170 | - if($quoteValue) |
|
| 170 | + if ($quoteValue) |
|
| 171 | 171 | { |
| 172 | 172 | $value = self::_quoteString($value); |
| 173 | 173 | } |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | return self::_buildIf($cmd, $condition, 'variable'); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - public static function if(string $condition, string $type='') : Mailcode_Commands_Command_If |
|
| 185 | + public static function if (string $condition, string $type = '') : Mailcode_Commands_Command_If |
|
| 186 | 186 | { |
| 187 | 187 | $cmd = self::_buildIf('If', $condition, $type); |
| 188 | 188 | |
| 189 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 189 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 190 | 190 | { |
| 191 | 191 | return $cmd; |
| 192 | 192 | } |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | throw self::_exceptionUnexpectedType($cmd); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If |
|
| 197 | + public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If |
|
| 198 | 198 | { |
| 199 | 199 | $cmd = self::_buildIfVar('If', $variable, $operand, $value, $quoteValue); |
| 200 | 200 | |
| 201 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 201 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 202 | 202 | { |
| 203 | 203 | return $cmd; |
| 204 | 204 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | $cmd = self::_buildIfVar('If', $variable, $operand, $value, true); |
| 212 | 212 | |
| 213 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 213 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 214 | 214 | { |
| 215 | 215 | return $cmd; |
| 216 | 216 | } |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | throw self::_exceptionUnexpectedType($cmd); |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - public static function ifVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If |
|
| 221 | + public static function ifVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If |
|
| 222 | 222 | { |
| 223 | 223 | $cmd = self::_buildIfVar('If', $variable, '==', $value, $quoteValue); |
| 224 | 224 | |
| 225 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 225 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 226 | 226 | { |
| 227 | 227 | return $cmd; |
| 228 | 228 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | { |
| 235 | 235 | $cmd = self::_buildIfVar('If', $variable, '==', $value, true); |
| 236 | 236 | |
| 237 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 237 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 238 | 238 | { |
| 239 | 239 | return $cmd; |
| 240 | 240 | } |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | throw self::_exceptionUnexpectedType($cmd); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If |
|
| 245 | + public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If |
|
| 246 | 246 | { |
| 247 | 247 | $cmd = self::_buildIfVar('If', $variable, '!=', $value, $quoteValue); |
| 248 | 248 | |
| 249 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 249 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 250 | 250 | { |
| 251 | 251 | return $cmd; |
| 252 | 252 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | { |
| 259 | 259 | $cmd = self::_buildIfVar('If', $variable, '!=', $value, true); |
| 260 | 260 | |
| 261 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 261 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 262 | 262 | { |
| 263 | 263 | return $cmd; |
| 264 | 264 | } |
@@ -266,11 +266,11 @@ discard block |
||
| 266 | 266 | throw self::_exceptionUnexpectedType($cmd); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - public static function elseIf(string $condition, string $type='') : Mailcode_Commands_Command_ElseIf |
|
| 269 | + public static function elseIf (string $condition, string $type = '') : Mailcode_Commands_Command_ElseIf |
|
| 270 | 270 | { |
| 271 | 271 | $cmd = self::_buildIf('ElseIf', $condition, $type); |
| 272 | 272 | |
| 273 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 273 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 274 | 274 | { |
| 275 | 275 | return $cmd; |
| 276 | 276 | } |
@@ -278,11 +278,11 @@ discard block |
||
| 278 | 278 | throw self::_exceptionUnexpectedType($cmd); |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf |
|
| 281 | + public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf |
|
| 282 | 282 | { |
| 283 | 283 | $cmd = self::_buildIfVar('ElseIf', $variable, $operand, $value, $quoteValue); |
| 284 | 284 | |
| 285 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 285 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 286 | 286 | { |
| 287 | 287 | return $cmd; |
| 288 | 288 | } |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | { |
| 295 | 295 | $cmd = self::_buildIfVar('ElseIf', $variable, $operand, $value, true); |
| 296 | 296 | |
| 297 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 297 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 298 | 298 | { |
| 299 | 299 | return $cmd; |
| 300 | 300 | } |
@@ -302,11 +302,11 @@ discard block |
||
| 302 | 302 | throw self::_exceptionUnexpectedType($cmd); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf |
|
| 305 | + public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf |
|
| 306 | 306 | { |
| 307 | 307 | $cmd = self::_buildIfVar('ElseIf', $variable, '==', $value, $quoteValue); |
| 308 | 308 | |
| 309 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 309 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 310 | 310 | { |
| 311 | 311 | return $cmd; |
| 312 | 312 | } |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | { |
| 319 | 319 | $cmd = self::_buildIfVar('ElseIf', $variable, '==', $value, true); |
| 320 | 320 | |
| 321 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 321 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 322 | 322 | { |
| 323 | 323 | return $cmd; |
| 324 | 324 | } |
@@ -326,11 +326,11 @@ discard block |
||
| 326 | 326 | throw self::_exceptionUnexpectedType($cmd); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf |
|
| 329 | + public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf |
|
| 330 | 330 | { |
| 331 | 331 | $cmd = self::_buildIfVar('ElseIf', $variable, '!=', $value, $quoteValue); |
| 332 | 332 | |
| 333 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 333 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 334 | 334 | { |
| 335 | 335 | return $cmd; |
| 336 | 336 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | { |
| 343 | 343 | $cmd = self::_buildIfVar('ElseIf', $variable, '!=', $value, true); |
| 344 | 344 | |
| 345 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 345 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 346 | 346 | { |
| 347 | 347 | return $cmd; |
| 348 | 348 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | |
| 369 | 369 | protected static function _checkCommand(Mailcode_Commands_Command $command) : void |
| 370 | 370 | { |
| 371 | - if($command->isValid()) |
|
| 371 | + if ($command->isValid()) |
|
| 372 | 372 | { |
| 373 | 373 | return; |
| 374 | 374 | } |
@@ -30,53 +30,53 @@ discard block |
||
| 30 | 30 | const VALIDATION_UNKNOWN_COMMAND_NAME = 48304; |
| 31 | 31 | const VALIDATION_INVALID_PARAMS_STATEMENT = 48305; |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 33 | + /** |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | 36 | protected $type = ''; |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var string |
|
| 40 | - */ |
|
| 38 | + /** |
|
| 39 | + * @var string |
|
| 40 | + */ |
|
| 41 | 41 | protected $paramsString = ''; |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var string |
|
| 45 | - */ |
|
| 43 | + /** |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | 46 | protected $matchedText = ''; |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var string |
|
| 50 | - */ |
|
| 48 | + /** |
|
| 49 | + * @var string |
|
| 50 | + */ |
|
| 51 | 51 | protected $hash = ''; |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @var \AppUtils\OperationResult |
|
| 55 | - */ |
|
| 53 | + /** |
|
| 54 | + * @var \AppUtils\OperationResult |
|
| 55 | + */ |
|
| 56 | 56 | protected $validationResult = null; |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @var \Mailcode\Mailcode |
|
| 60 | - */ |
|
| 58 | + /** |
|
| 59 | + * @var \Mailcode\Mailcode |
|
| 60 | + */ |
|
| 61 | 61 | protected $mailcode; |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @var \Mailcode\Mailcode_Parser_Statement |
|
| 65 | - */ |
|
| 63 | + /** |
|
| 64 | + * @var \Mailcode\Mailcode_Parser_Statement |
|
| 65 | + */ |
|
| 66 | 66 | protected $params; |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @var string[] |
|
| 70 | - */ |
|
| 68 | + /** |
|
| 69 | + * @var string[] |
|
| 70 | + */ |
|
| 71 | 71 | protected $validations = array( |
| 72 | 72 | 'params', |
| 73 | 73 | 'type_supported', |
| 74 | 74 | 'type_unsupported' |
| 75 | 75 | ); |
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @var string |
|
| 79 | - */ |
|
| 77 | + /** |
|
| 78 | + * @var string |
|
| 79 | + */ |
|
| 80 | 80 | protected $comment = ''; |
| 81 | 81 | |
| 82 | 82 | public function __construct(string $type='', string $paramsString='', string $matchedText='') |
@@ -94,23 +94,23 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * @return string The ID of the command = the name of the command class file. |
|
| 99 | - */ |
|
| 97 | + /** |
|
| 98 | + * @return string The ID of the command = the name of the command class file. |
|
| 99 | + */ |
|
| 100 | 100 | public function getID() : string |
| 101 | 101 | { |
| 102 | 102 | $tokens = explode('_', get_class($this)); |
| 103 | 103 | return array_pop($tokens); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Sets an optional comment that is not used anywhere, but |
|
| 108 | - * can be used by the application to track why a command is |
|
| 109 | - * used somewhere. |
|
| 110 | - * |
|
| 111 | - * @param string $comment |
|
| 112 | - * @return Mailcode_Commands_Command |
|
| 113 | - */ |
|
| 106 | + /** |
|
| 107 | + * Sets an optional comment that is not used anywhere, but |
|
| 108 | + * can be used by the application to track why a command is |
|
| 109 | + * used somewhere. |
|
| 110 | + * |
|
| 111 | + * @param string $comment |
|
| 112 | + * @return Mailcode_Commands_Command |
|
| 113 | + */ |
|
| 114 | 114 | public function setComment(string $comment) : Mailcode_Commands_Command |
| 115 | 115 | { |
| 116 | 116 | $this->comment = $comment; |
@@ -118,34 +118,34 @@ discard block |
||
| 118 | 118 | return $this; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Retrieves the previously set comment, if any. |
|
| 123 | - * |
|
| 124 | - * @return string |
|
| 125 | - */ |
|
| 121 | + /** |
|
| 122 | + * Retrieves the previously set comment, if any. |
|
| 123 | + * |
|
| 124 | + * @return string |
|
| 125 | + */ |
|
| 126 | 126 | public function getComment() : string |
| 127 | 127 | { |
| 128 | 128 | return $this->comment; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * Checks whether this is a dummy command, which is only |
|
| 133 | - * used to access information on the command type. It cannot |
|
| 134 | - * be used as an actual live command. |
|
| 135 | - * |
|
| 136 | - * @return bool |
|
| 137 | - */ |
|
| 131 | + /** |
|
| 132 | + * Checks whether this is a dummy command, which is only |
|
| 133 | + * used to access information on the command type. It cannot |
|
| 134 | + * be used as an actual live command. |
|
| 135 | + * |
|
| 136 | + * @return bool |
|
| 137 | + */ |
|
| 138 | 138 | public function isDummy() : bool |
| 139 | 139 | { |
| 140 | 140 | return $this->type === '__dummy'; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * Retrieves a hash of the actual matched command string, |
|
| 145 | - * which is used in collections to detect duplicate commands. |
|
| 146 | - * |
|
| 147 | - * @return string |
|
| 148 | - */ |
|
| 143 | + /** |
|
| 144 | + * Retrieves a hash of the actual matched command string, |
|
| 145 | + * which is used in collections to detect duplicate commands. |
|
| 146 | + * |
|
| 147 | + * @return string |
|
| 148 | + */ |
|
| 149 | 149 | public function getHash() : string |
| 150 | 150 | { |
| 151 | 151 | $this->requireNonDummy(); |
@@ -237,9 +237,9 @@ discard block |
||
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - /** |
|
| 241 | - * @return string[] |
|
| 242 | - */ |
|
| 240 | + /** |
|
| 241 | + * @return string[] |
|
| 242 | + */ |
|
| 243 | 243 | abstract protected function getValidations() : array; |
| 244 | 244 | |
| 245 | 245 | protected function validateSyntax_params() : void |
@@ -394,22 +394,22 @@ discard block |
||
| 394 | 394 | return implode('', $parts); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - /** |
|
| 398 | - * Retrieves the names of all the command's supported types: the part |
|
| 399 | - * between the command name and the colon. Example: {command type: params}. |
|
| 400 | - * |
|
| 401 | - * @return string[] |
|
| 402 | - */ |
|
| 397 | + /** |
|
| 398 | + * Retrieves the names of all the command's supported types: the part |
|
| 399 | + * between the command name and the colon. Example: {command type: params}. |
|
| 400 | + * |
|
| 401 | + * @return string[] |
|
| 402 | + */ |
|
| 403 | 403 | public function getSupportedTypes() : array |
| 404 | 404 | { |
| 405 | 405 | return array(); |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - /** |
|
| 409 | - * Retrieves all variable names used in the command. |
|
| 410 | - * |
|
| 411 | - * @return Mailcode_Variables_Collection_Regular |
|
| 412 | - */ |
|
| 408 | + /** |
|
| 409 | + * Retrieves all variable names used in the command. |
|
| 410 | + * |
|
| 411 | + * @return Mailcode_Variables_Collection_Regular |
|
| 412 | + */ |
|
| 413 | 413 | public function getVariables() : Mailcode_Variables_Collection_Regular |
| 414 | 414 | { |
| 415 | 415 | return Mailcode::create()->findVariables($this->paramsString); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | protected $comment = ''; |
| 81 | 81 | |
| 82 | - public function __construct(string $type='', string $paramsString='', string $matchedText='') |
|
| 82 | + public function __construct(string $type = '', string $paramsString = '', string $matchedText = '') |
|
| 83 | 83 | { |
| 84 | 84 | $this->type = $type; |
| 85 | 85 | $this->paramsString = $paramsString; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | { |
| 151 | 151 | $this->requireNonDummy(); |
| 152 | 152 | |
| 153 | - if($this->hash === '') { |
|
| 153 | + if ($this->hash === '') { |
|
| 154 | 154 | $this->hash = md5($this->matchedText); |
| 155 | 155 | } |
| 156 | 156 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | protected function requireNonDummy() : void |
| 161 | 161 | { |
| 162 | - if(!$this->isDummy()) |
|
| 162 | + if (!$this->isDummy()) |
|
| 163 | 163 | { |
| 164 | 164 | return; |
| 165 | 165 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | { |
| 181 | 181 | $this->requireNonDummy(); |
| 182 | 182 | |
| 183 | - if(isset($this->validationResult)) |
|
| 183 | + if (isset($this->validationResult)) |
|
| 184 | 184 | { |
| 185 | 185 | return $this->validationResult; |
| 186 | 186 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | public function getValidationResult() : \AppUtils\OperationResult |
| 196 | 196 | { |
| 197 | - if(isset($this->validationResult)) |
|
| 197 | + if (isset($this->validationResult)) |
|
| 198 | 198 | { |
| 199 | 199 | return $this->validationResult; |
| 200 | 200 | } |
@@ -210,11 +210,11 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | $validations = array_merge($this->validations, $this->getValidations()); |
| 212 | 212 | |
| 213 | - foreach($validations as $validation) |
|
| 213 | + foreach ($validations as $validation) |
|
| 214 | 214 | { |
| 215 | 215 | $method = 'validateSyntax_'.$validation; |
| 216 | 216 | |
| 217 | - if(!method_exists($this, $method)) |
|
| 217 | + if (!method_exists($this, $method)) |
|
| 218 | 218 | { |
| 219 | 219 | throw new Mailcode_Exception( |
| 220 | 220 | 'Missing validation method', |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $this->$method(); |
| 231 | 231 | |
| 232 | 232 | // break off at the first validation issue |
| 233 | - if(!$this->validationResult->isValid()) |
|
| 233 | + if (!$this->validationResult->isValid()) |
|
| 234 | 234 | { |
| 235 | 235 | return; |
| 236 | 236 | } |
@@ -244,12 +244,12 @@ discard block |
||
| 244 | 244 | |
| 245 | 245 | protected function validateSyntax_params() : void |
| 246 | 246 | { |
| 247 | - if(!$this->requiresParameters()) |
|
| 247 | + if (!$this->requiresParameters()) |
|
| 248 | 248 | { |
| 249 | 249 | return; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if(empty($this->paramsString)) |
|
| 252 | + if (empty($this->paramsString)) |
|
| 253 | 253 | { |
| 254 | 254 | $this->validationResult->makeError( |
| 255 | 255 | t('Parameters have to be specified.'), |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | $this->params = $this->mailcode->getParser()->createStatement($this->paramsString); |
| 262 | 262 | |
| 263 | - if(!$this->params->isValid()) |
|
| 263 | + if (!$this->params->isValid()) |
|
| 264 | 264 | { |
| 265 | 265 | $error = $this->params->getValidationResult(); |
| 266 | 266 | |
@@ -273,14 +273,14 @@ discard block |
||
| 273 | 273 | |
| 274 | 274 | protected function validateSyntax_type_supported() : void |
| 275 | 275 | { |
| 276 | - if(!$this->supportsType() || empty($this->type)) |
|
| 276 | + if (!$this->supportsType() || empty($this->type)) |
|
| 277 | 277 | { |
| 278 | 278 | return; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | $types = $this->getSupportedTypes(); |
| 282 | 282 | |
| 283 | - if(!in_array($this->type, $types)) |
|
| 283 | + if (!in_array($this->type, $types)) |
|
| 284 | 284 | { |
| 285 | 285 | $this->validationResult->makeError( |
| 286 | 286 | t('The command addon %1$s is not supported.', $this->type).' '. |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | |
| 295 | 295 | protected function validateSyntax_type_unsupported() : void |
| 296 | 296 | { |
| 297 | - if($this->supportsType() || empty($this->type)) |
|
| 297 | + if ($this->supportsType() || empty($this->type)) |
|
| 298 | 298 | { |
| 299 | 299 | return; |
| 300 | 300 | } |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | |
| 313 | 313 | public function getType() : string |
| 314 | 314 | { |
| 315 | - if($this->supportsType()) |
|
| 315 | + if ($this->supportsType()) |
|
| 316 | 316 | { |
| 317 | 317 | return $this->type; |
| 318 | 318 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | |
| 333 | 333 | public function getHighlighted() : string |
| 334 | 334 | { |
| 335 | - if(!$this->isValid()) |
|
| 335 | + if (!$this->isValid()) |
|
| 336 | 336 | { |
| 337 | 337 | return ''; |
| 338 | 338 | } |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | public function getParamsString() : string |
| 345 | 345 | { |
| 346 | - if($this->requiresParameters()) |
|
| 346 | + if ($this->requiresParameters()) |
|
| 347 | 347 | { |
| 348 | 348 | return $this->paramsString; |
| 349 | 349 | } |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | |
| 371 | 371 | public function getNormalized() : string |
| 372 | 372 | { |
| 373 | - if(!$this->isValid()) |
|
| 373 | + if (!$this->isValid()) |
|
| 374 | 374 | { |
| 375 | 375 | return ''; |
| 376 | 376 | } |
@@ -378,12 +378,12 @@ discard block |
||
| 378 | 378 | $parts = array(); |
| 379 | 379 | $parts[] = '{'.$this->getName(); |
| 380 | 380 | |
| 381 | - if($this->supportsType() && $this->hasType()) |
|
| 381 | + if ($this->supportsType() && $this->hasType()) |
|
| 382 | 382 | { |
| 383 | 383 | $parts[] = ' '.$this->getType(); |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - if($this->requiresParameters() && isset($this->params)) |
|
| 386 | + if ($this->requiresParameters() && isset($this->params)) |
|
| 387 | 387 | { |
| 388 | 388 | $parts[] = ': '; |
| 389 | 389 | $parts[] = $this->params->getNormalized(); |
@@ -57,45 +57,45 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | const ERROR_PLACEHOLDER_NOT_FOUND = 47804; |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @var Mailcode_Parser |
|
| 62 | - */ |
|
| 60 | + /** |
|
| 61 | + * @var Mailcode_Parser |
|
| 62 | + */ |
|
| 63 | 63 | protected $parser; |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @var Mailcode_Collection |
|
| 67 | - */ |
|
| 65 | + /** |
|
| 66 | + * @var Mailcode_Collection |
|
| 67 | + */ |
|
| 68 | 68 | protected $commands; |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * @var string |
|
| 72 | - */ |
|
| 70 | + /** |
|
| 71 | + * @var string |
|
| 72 | + */ |
|
| 73 | 73 | protected $originalString; |
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @var Mailcode_Collection |
|
| 77 | - */ |
|
| 75 | + /** |
|
| 76 | + * @var Mailcode_Collection |
|
| 77 | + */ |
|
| 78 | 78 | protected $collection; |
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Counter for the placeholders, global for all placeholders. |
|
| 82 | - * @var integer |
|
| 83 | - */ |
|
| 80 | + /** |
|
| 81 | + * Counter for the placeholders, global for all placeholders. |
|
| 82 | + * @var integer |
|
| 83 | + */ |
|
| 84 | 84 | private static $counter = 0; |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * @var Mailcode_Parser_Safeguard_Placeholder[] |
|
| 88 | - */ |
|
| 86 | + /** |
|
| 87 | + * @var Mailcode_Parser_Safeguard_Placeholder[] |
|
| 88 | + */ |
|
| 89 | 89 | protected $placeholders; |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @var string |
|
| 93 | - */ |
|
| 91 | + /** |
|
| 92 | + * @var string |
|
| 93 | + */ |
|
| 94 | 94 | protected $delimiter = '__'; |
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * @var array|NULL |
|
| 98 | - */ |
|
| 96 | + /** |
|
| 97 | + * @var array|NULL |
|
| 98 | + */ |
|
| 99 | 99 | protected $placeholderStrings; |
| 100 | 100 | |
| 101 | 101 | public function __construct(Mailcode_Parser $parser, string $subject) |
@@ -104,15 +104,15 @@ discard block |
||
| 104 | 104 | $this->originalString = $subject; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * Sets the delimiter character sequence used to prepend |
|
| 109 | - * and append to the placeholders. |
|
| 110 | - * |
|
| 111 | - * The delimiter's default is "__" (two underscores). |
|
| 112 | - * |
|
| 113 | - * @param string $delimiter |
|
| 114 | - * @return Mailcode_Parser_Safeguard |
|
| 115 | - */ |
|
| 107 | + /** |
|
| 108 | + * Sets the delimiter character sequence used to prepend |
|
| 109 | + * and append to the placeholders. |
|
| 110 | + * |
|
| 111 | + * The delimiter's default is "__" (two underscores). |
|
| 112 | + * |
|
| 113 | + * @param string $delimiter |
|
| 114 | + * @return Mailcode_Parser_Safeguard |
|
| 115 | + */ |
|
| 116 | 116 | public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard |
| 117 | 117 | { |
| 118 | 118 | if(empty($delimiter)) |
@@ -134,15 +134,15 @@ discard block |
||
| 134 | 134 | return $this->delimiter; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Retrieves the safe string in which all commands have been replaced |
|
| 139 | - * by placeholder strings. |
|
| 140 | - * |
|
| 141 | - * @return string |
|
| 142 | - * @throws Mailcode_Exception |
|
| 143 | - * |
|
| 144 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 145 | - */ |
|
| 137 | + /** |
|
| 138 | + * Retrieves the safe string in which all commands have been replaced |
|
| 139 | + * by placeholder strings. |
|
| 140 | + * |
|
| 141 | + * @return string |
|
| 142 | + * @throws Mailcode_Exception |
|
| 143 | + * |
|
| 144 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 145 | + */ |
|
| 146 | 146 | public function makeSafe() : string |
| 147 | 147 | { |
| 148 | 148 | $this->requireValidCollection(); |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | return str_replace(array_values($replaces), array_keys($replaces), $this->originalString); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * @param bool $highlighted |
|
| 157 | - * @return string[]string |
|
| 158 | - */ |
|
| 155 | + /** |
|
| 156 | + * @param bool $highlighted |
|
| 157 | + * @return string[]string |
|
| 158 | + */ |
|
| 159 | 159 | protected function getReplaces(bool $highlighted=false) : array |
| 160 | 160 | { |
| 161 | 161 | $placeholders = $this->getPlaceholders(); |
@@ -182,12 +182,12 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Retrieves all placeholders that have to be added to |
|
| 187 | - * the subject text. |
|
| 188 | - * |
|
| 189 | - * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[] |
|
| 190 | - */ |
|
| 185 | + /** |
|
| 186 | + * Retrieves all placeholders that have to be added to |
|
| 187 | + * the subject text. |
|
| 188 | + * |
|
| 189 | + * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[] |
|
| 190 | + */ |
|
| 191 | 191 | public function getPlaceholders() |
| 192 | 192 | { |
| 193 | 193 | if(isset($this->placeholders)) |
@@ -239,46 +239,46 @@ discard block |
||
| 239 | 239 | return str_replace($placeholderStrings, array_values($replaces), $string); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - /** |
|
| 243 | - * Makes the string whole again after transforming or filtering it, |
|
| 244 | - * by replacing the command placeholders with the original commands. |
|
| 245 | - * |
|
| 246 | - * @param string $string |
|
| 247 | - * @return string |
|
| 248 | - * @throws Mailcode_Exception |
|
| 249 | - * |
|
| 250 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 251 | - * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING |
|
| 252 | - */ |
|
| 242 | + /** |
|
| 243 | + * Makes the string whole again after transforming or filtering it, |
|
| 244 | + * by replacing the command placeholders with the original commands. |
|
| 245 | + * |
|
| 246 | + * @param string $string |
|
| 247 | + * @return string |
|
| 248 | + * @throws Mailcode_Exception |
|
| 249 | + * |
|
| 250 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 251 | + * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING |
|
| 252 | + */ |
|
| 253 | 253 | public function makeWhole(string $string) : string |
| 254 | 254 | { |
| 255 | 255 | return $this->restore($string, false); |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - /** |
|
| 259 | - * Like makeWhole(), but replaces the commands with a syntax |
|
| 260 | - * highlighted version, meant for human readable texts only. |
|
| 261 | - * |
|
| 262 | - * Note: the commands lose their functionality (They cannot be |
|
| 263 | - * parsed from that string again). |
|
| 264 | - * |
|
| 265 | - * @param string $string |
|
| 266 | - * @return string |
|
| 267 | - * @throws Mailcode_Exception |
|
| 268 | - * |
|
| 269 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 270 | - * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING |
|
| 271 | - */ |
|
| 258 | + /** |
|
| 259 | + * Like makeWhole(), but replaces the commands with a syntax |
|
| 260 | + * highlighted version, meant for human readable texts only. |
|
| 261 | + * |
|
| 262 | + * Note: the commands lose their functionality (They cannot be |
|
| 263 | + * parsed from that string again). |
|
| 264 | + * |
|
| 265 | + * @param string $string |
|
| 266 | + * @return string |
|
| 267 | + * @throws Mailcode_Exception |
|
| 268 | + * |
|
| 269 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 270 | + * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING |
|
| 271 | + */ |
|
| 272 | 272 | public function makeHighlighted(string $string) : string |
| 273 | 273 | { |
| 274 | 274 | return $this->restore($string, true); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - /** |
|
| 278 | - * Retrieves the commands collection contained in the string. |
|
| 279 | - * |
|
| 280 | - * @return Mailcode_Collection |
|
| 281 | - */ |
|
| 277 | + /** |
|
| 278 | + * Retrieves the commands collection contained in the string. |
|
| 279 | + * |
|
| 280 | + * @return Mailcode_Collection |
|
| 281 | + */ |
|
| 282 | 282 | public function getCollection() : Mailcode_Collection |
| 283 | 283 | { |
| 284 | 284 | if(isset($this->collection)) |
@@ -296,11 +296,11 @@ discard block |
||
| 296 | 296 | return $this->getCollection()->isValid(); |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - /** |
|
| 300 | - * @throws Mailcode_Exception |
|
| 301 | - * |
|
| 302 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 303 | - */ |
|
| 299 | + /** |
|
| 300 | + * @throws Mailcode_Exception |
|
| 301 | + * |
|
| 302 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
| 303 | + */ |
|
| 304 | 304 | protected function requireValidCollection() : void |
| 305 | 305 | { |
| 306 | 306 | if($this->getCollection()->isValid()) |
@@ -318,11 +318,11 @@ discard block |
||
| 318 | 318 | ); |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - /** |
|
| 322 | - * Retrieves a list of all placeholder IDs used in the text. |
|
| 323 | - * |
|
| 324 | - * @return string[] |
|
| 325 | - */ |
|
| 321 | + /** |
|
| 322 | + * Retrieves a list of all placeholder IDs used in the text. |
|
| 323 | + * |
|
| 324 | + * @return string[] |
|
| 325 | + */ |
|
| 326 | 326 | public function getPlaceholderStrings() : array |
| 327 | 327 | { |
| 328 | 328 | if(isset($this->placeholderStrings)) |
@@ -349,13 +349,13 @@ discard block |
||
| 349 | 349 | return in_array($subject, $ids); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - /** |
|
| 353 | - * Retrieves a placeholder instance by its ID. |
|
| 354 | - * |
|
| 355 | - * @param int $id |
|
| 356 | - * @throws Mailcode_Exception If the placeholder was not found. |
|
| 357 | - * @return Mailcode_Parser_Safeguard_Placeholder |
|
| 358 | - */ |
|
| 352 | + /** |
|
| 353 | + * Retrieves a placeholder instance by its ID. |
|
| 354 | + * |
|
| 355 | + * @param int $id |
|
| 356 | + * @throws Mailcode_Exception If the placeholder was not found. |
|
| 357 | + * @return Mailcode_Parser_Safeguard_Placeholder |
|
| 358 | + */ |
|
| 359 | 359 | public function getPlaceholderByID(int $id) : Mailcode_Parser_Safeguard_Placeholder |
| 360 | 360 | { |
| 361 | 361 | $placeholders = $this->getPlaceholders(); |
@@ -378,13 +378,13 @@ discard block |
||
| 378 | 378 | ); |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - /** |
|
| 382 | - * Retrieves a placeholder instance by its replacement text. |
|
| 383 | - * |
|
| 384 | - * @param string $string |
|
| 385 | - * @throws Mailcode_Exception |
|
| 386 | - * @return Mailcode_Parser_Safeguard_Placeholder |
|
| 387 | - */ |
|
| 381 | + /** |
|
| 382 | + * Retrieves a placeholder instance by its replacement text. |
|
| 383 | + * |
|
| 384 | + * @param string $string |
|
| 385 | + * @throws Mailcode_Exception |
|
| 386 | + * @return Mailcode_Parser_Safeguard_Placeholder |
|
| 387 | + */ |
|
| 388 | 388 | public function getPlaceholderByString(string $string) : Mailcode_Parser_Safeguard_Placeholder |
| 389 | 389 | { |
| 390 | 390 | $placeholders = $this->getPlaceholders(); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard |
| 117 | 117 | { |
| 118 | - if(empty($delimiter)) |
|
| 118 | + if (empty($delimiter)) |
|
| 119 | 119 | { |
| 120 | 120 | throw new Mailcode_Exception( |
| 121 | 121 | 'Empty delimiter', |
@@ -156,17 +156,17 @@ discard block |
||
| 156 | 156 | * @param bool $highlighted |
| 157 | 157 | * @return string[]string |
| 158 | 158 | */ |
| 159 | - protected function getReplaces(bool $highlighted=false) : array |
|
| 159 | + protected function getReplaces(bool $highlighted = false) : array |
|
| 160 | 160 | { |
| 161 | 161 | $placeholders = $this->getPlaceholders(); |
| 162 | 162 | |
| 163 | 163 | $replaces = array(); |
| 164 | 164 | |
| 165 | - foreach($placeholders as $placeholder) |
|
| 165 | + foreach ($placeholders as $placeholder) |
|
| 166 | 166 | { |
| 167 | 167 | $replace = ''; |
| 168 | 168 | |
| 169 | - if($highlighted) |
|
| 169 | + if ($highlighted) |
|
| 170 | 170 | { |
| 171 | 171 | $replace = $placeholder->getHighlightedText(); |
| 172 | 172 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public function getPlaceholders() |
| 192 | 192 | { |
| 193 | - if(isset($this->placeholders)) |
|
| 193 | + if (isset($this->placeholders)) |
|
| 194 | 194 | { |
| 195 | 195 | return $this->placeholders; |
| 196 | 196 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | $cmds = $this->getCollection()->getGroupedByHash(); |
| 201 | 201 | |
| 202 | - foreach($cmds as $command) |
|
| 202 | + foreach ($cmds as $command) |
|
| 203 | 203 | { |
| 204 | 204 | self::$counter++; |
| 205 | 205 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | return $this->placeholders; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - protected function restore(string $string, bool $highlighted=false) : string |
|
| 216 | + protected function restore(string $string, bool $highlighted = false) : string |
|
| 217 | 217 | { |
| 218 | 218 | $this->requireValidCollection(); |
| 219 | 219 | |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | $placeholderStrings = array_keys($replaces); |
| 223 | 223 | |
| 224 | - foreach($placeholderStrings as $search) |
|
| 224 | + foreach ($placeholderStrings as $search) |
|
| 225 | 225 | { |
| 226 | - if(!strstr($string, $search)) |
|
| 226 | + if (!strstr($string, $search)) |
|
| 227 | 227 | { |
| 228 | 228 | throw new Mailcode_Exception( |
| 229 | 229 | 'Command placeholder not found', |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | public function getCollection() : Mailcode_Collection |
| 283 | 283 | { |
| 284 | - if(isset($this->collection)) |
|
| 284 | + if (isset($this->collection)) |
|
| 285 | 285 | { |
| 286 | 286 | return $this->collection; |
| 287 | 287 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | */ |
| 304 | 304 | protected function requireValidCollection() : void |
| 305 | 305 | { |
| 306 | - if($this->getCollection()->isValid()) |
|
| 306 | + if ($this->getCollection()->isValid()) |
|
| 307 | 307 | { |
| 308 | 308 | return; |
| 309 | 309 | } |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public function getPlaceholderStrings() : array |
| 327 | 327 | { |
| 328 | - if(isset($this->placeholderStrings)) |
|
| 328 | + if (isset($this->placeholderStrings)) |
|
| 329 | 329 | { |
| 330 | 330 | return $this->placeholderStrings; |
| 331 | 331 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | $this->placeholderStrings = array(); |
| 336 | 336 | |
| 337 | - foreach($placeholders as $placeholder) |
|
| 337 | + foreach ($placeholders as $placeholder) |
|
| 338 | 338 | { |
| 339 | 339 | $this->placeholderStrings[] = $placeholder->getReplacementText(); |
| 340 | 340 | } |
@@ -360,9 +360,9 @@ discard block |
||
| 360 | 360 | { |
| 361 | 361 | $placeholders = $this->getPlaceholders(); |
| 362 | 362 | |
| 363 | - foreach($placeholders as $placeholder) |
|
| 363 | + foreach ($placeholders as $placeholder) |
|
| 364 | 364 | { |
| 365 | - if($placeholder->getID() === $id) |
|
| 365 | + if ($placeholder->getID() === $id) |
|
| 366 | 366 | { |
| 367 | 367 | return $placeholder; |
| 368 | 368 | } |
@@ -389,9 +389,9 @@ discard block |
||
| 389 | 389 | { |
| 390 | 390 | $placeholders = $this->getPlaceholders(); |
| 391 | 391 | |
| 392 | - foreach($placeholders as $placeholder) |
|
| 392 | + foreach ($placeholders as $placeholder) |
|
| 393 | 393 | { |
| 394 | - if($placeholder->getReplacementText() === $string) |
|
| 394 | + if ($placeholder->getReplacementText() === $string) |
|
| 395 | 395 | { |
| 396 | 396 | return $placeholder; |
| 397 | 397 | } |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | class Mailcode_Collection |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * @var Mailcode_Commands_Command[] |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var Mailcode_Commands_Command[] |
|
| 27 | + */ |
|
| 28 | 28 | protected $commands = array(); |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -32,17 +32,17 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | protected $errors = array(); |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var OperationResult|NULL |
|
| 37 | - */ |
|
| 35 | + /** |
|
| 36 | + * @var OperationResult|NULL |
|
| 37 | + */ |
|
| 38 | 38 | protected $validationResult; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Adds a command to the collection. |
|
| 42 | - * |
|
| 43 | - * @param Mailcode_Commands_Command $command |
|
| 44 | - * @return Mailcode_Collection |
|
| 45 | - */ |
|
| 40 | + /** |
|
| 41 | + * Adds a command to the collection. |
|
| 42 | + * |
|
| 43 | + * @param Mailcode_Commands_Command $command |
|
| 44 | + * @return Mailcode_Collection |
|
| 45 | + */ |
|
| 46 | 46 | public function addCommand(Mailcode_Commands_Command $command) : Mailcode_Collection |
| 47 | 47 | { |
| 48 | 48 | $this->commands[] = $command; |
@@ -54,21 +54,21 @@ discard block |
||
| 54 | 54 | return $this; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Whether there are any commands in the collection. |
|
| 59 | - * |
|
| 60 | - * @return bool |
|
| 61 | - */ |
|
| 57 | + /** |
|
| 58 | + * Whether there are any commands in the collection. |
|
| 59 | + * |
|
| 60 | + * @return bool |
|
| 61 | + */ |
|
| 62 | 62 | public function hasCommands() : bool |
| 63 | 63 | { |
| 64 | 64 | return !empty($this->commands); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Counts the amount of commands in the collection. |
|
| 69 | - * |
|
| 70 | - * @return int |
|
| 71 | - */ |
|
| 67 | + /** |
|
| 68 | + * Counts the amount of commands in the collection. |
|
| 69 | + * |
|
| 70 | + * @return int |
|
| 71 | + */ |
|
| 72 | 72 | public function countCommands() : int |
| 73 | 73 | { |
| 74 | 74 | return count($this->commands); |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | $this->errors[] = new Mailcode_Collection_Error_Command($command); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @return Mailcode_Collection_Error[] |
|
| 93 | - */ |
|
| 91 | + /** |
|
| 92 | + * @return Mailcode_Collection_Error[] |
|
| 93 | + */ |
|
| 94 | 94 | public function getErrors() |
| 95 | 95 | { |
| 96 | 96 | $result = $this->getValidationResult(); |
@@ -116,25 +116,25 @@ discard block |
||
| 116 | 116 | return empty($errors); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Retrieves all commands that were detected, in the exact order |
|
| 121 | - * they were found. |
|
| 122 | - * |
|
| 123 | - * @return \Mailcode\Mailcode_Commands_Command[] |
|
| 124 | - */ |
|
| 119 | + /** |
|
| 120 | + * Retrieves all commands that were detected, in the exact order |
|
| 121 | + * they were found. |
|
| 122 | + * |
|
| 123 | + * @return \Mailcode\Mailcode_Commands_Command[] |
|
| 124 | + */ |
|
| 125 | 125 | public function getCommands() |
| 126 | 126 | { |
| 127 | - return $this->commands; |
|
| 127 | + return $this->commands; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Retrieves all unique commands by their matched |
|
| 132 | - * string hash: this ensures only commands that were |
|
| 133 | - * written the exact same way (including spacing) |
|
| 134 | - * are returned. |
|
| 135 | - * |
|
| 136 | - * @return \Mailcode\Mailcode_Commands_Command[] |
|
| 137 | - */ |
|
| 130 | + /** |
|
| 131 | + * Retrieves all unique commands by their matched |
|
| 132 | + * string hash: this ensures only commands that were |
|
| 133 | + * written the exact same way (including spacing) |
|
| 134 | + * are returned. |
|
| 135 | + * |
|
| 136 | + * @return \Mailcode\Mailcode_Commands_Command[] |
|
| 137 | + */ |
|
| 138 | 138 | public function getGroupedByHash() |
| 139 | 139 | { |
| 140 | 140 | $hashes = array(); |
@@ -152,12 +152,12 @@ discard block |
||
| 152 | 152 | return array_values($hashes); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * Adds several commands at once. |
|
| 157 | - * |
|
| 158 | - * @param Mailcode_Commands_Command[] $commands |
|
| 159 | - * @return Mailcode_Collection |
|
| 160 | - */ |
|
| 155 | + /** |
|
| 156 | + * Adds several commands at once. |
|
| 157 | + * |
|
| 158 | + * @param Mailcode_Commands_Command[] $commands |
|
| 159 | + * @return Mailcode_Collection |
|
| 160 | + */ |
|
| 161 | 161 | public function addCommands(array $commands) : Mailcode_Collection |
| 162 | 162 | { |
| 163 | 163 | foreach($commands as $command) |
@@ -216,11 +216,11 @@ discard block |
||
| 216 | 216 | return false; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - /** |
|
| 220 | - * Retrieves only show variable commands in the collection, if any. |
|
| 221 | - * |
|
| 222 | - * @return \Mailcode\Mailcode_Commands_Command_ShowVariable[] |
|
| 223 | - */ |
|
| 219 | + /** |
|
| 220 | + * Retrieves only show variable commands in the collection, if any. |
|
| 221 | + * |
|
| 222 | + * @return \Mailcode\Mailcode_Commands_Command_ShowVariable[] |
|
| 223 | + */ |
|
| 224 | 224 | public function getShowVariableCommands() |
| 225 | 225 | { |
| 226 | 226 | $result = array(); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | $errors = $this->errors; |
| 99 | 99 | |
| 100 | - if(!$result->isValid()) |
|
| 100 | + if (!$result->isValid()) |
|
| 101 | 101 | { |
| 102 | 102 | $errors[] = new Mailcode_Collection_Error_Message( |
| 103 | 103 | '', |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | $hashes = array(); |
| 141 | 141 | |
| 142 | - foreach($this->commands as $command) |
|
| 142 | + foreach ($this->commands as $command) |
|
| 143 | 143 | { |
| 144 | 144 | $hash = $command->getHash(); |
| 145 | 145 | |
| 146 | - if(!isset($hashes[$hash])) |
|
| 146 | + if (!isset($hashes[$hash])) |
|
| 147 | 147 | { |
| 148 | 148 | $hashes[$hash] = $command; |
| 149 | 149 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function addCommands(array $commands) : Mailcode_Collection |
| 162 | 162 | { |
| 163 | - foreach($commands as $command) |
|
| 163 | + foreach ($commands as $command) |
|
| 164 | 164 | { |
| 165 | 165 | $this->addCommand($command); |
| 166 | 166 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | { |
| 180 | 180 | $collection = new Mailcode_Variables_Collection_Regular(); |
| 181 | 181 | |
| 182 | - foreach($this->commands as $command) |
|
| 182 | + foreach ($this->commands as $command) |
|
| 183 | 183 | { |
| 184 | 184 | $collection->mergeWith($command->getVariables()); |
| 185 | 185 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | public function getValidationResult() : OperationResult |
| 191 | 191 | { |
| 192 | - if(isset($this->validationResult)) |
|
| 192 | + if (isset($this->validationResult)) |
|
| 193 | 193 | { |
| 194 | 194 | return $this->validationResult; |
| 195 | 195 | } |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | { |
| 206 | 206 | $errors = $this->getErrors(); |
| 207 | 207 | |
| 208 | - foreach($errors as $error) |
|
| 208 | + foreach ($errors as $error) |
|
| 209 | 209 | { |
| 210 | - if($error->getCode() === $code) |
|
| 210 | + if ($error->getCode() === $code) |
|
| 211 | 211 | { |
| 212 | 212 | return true; |
| 213 | 213 | } |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | { |
| 226 | 226 | $result = array(); |
| 227 | 227 | |
| 228 | - foreach($this->commands as $command) |
|
| 228 | + foreach ($this->commands as $command) |
|
| 229 | 229 | { |
| 230 | - if($command instanceof Mailcode_Commands_Command_ShowVariable) |
|
| 230 | + if ($command instanceof Mailcode_Commands_Command_ShowVariable) |
|
| 231 | 231 | { |
| 232 | 232 | $result[] = $command; |
| 233 | 233 | } |
@@ -21,17 +21,17 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class Mailcode_Renderer |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * @var boolean |
|
| 26 | - */ |
|
| 24 | + /** |
|
| 25 | + * @var boolean |
|
| 26 | + */ |
|
| 27 | 27 | protected $highlighted = false; |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Sets whether to output highlighted commands instead of the default plain text. |
|
| 31 | - * |
|
| 32 | - * @param bool $highlighted |
|
| 33 | - * @return Mailcode_Renderer |
|
| 34 | - */ |
|
| 29 | + /** |
|
| 30 | + * Sets whether to output highlighted commands instead of the default plain text. |
|
| 31 | + * |
|
| 32 | + * @param bool $highlighted |
|
| 33 | + * @return Mailcode_Renderer |
|
| 34 | + */ |
|
| 35 | 35 | public function setOutputHighlighted(bool $highlighted=true) : Mailcode_Renderer |
| 36 | 36 | { |
| 37 | 37 | $this->highlighted = $highlighted; |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | return $this; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Converts a show variable command to string. |
|
| 44 | - * |
|
| 45 | - * @param string $variableName The variable name, with or without $ sign. |
|
| 46 | - * @return string |
|
| 47 | - */ |
|
| 42 | + /** |
|
| 43 | + * Converts a show variable command to string. |
|
| 44 | + * |
|
| 45 | + * @param string $variableName The variable name, with or without $ sign. |
|
| 46 | + * @return string |
|
| 47 | + */ |
|
| 48 | 48 | public function showVar(string $variableName) : string |
| 49 | 49 | { |
| 50 | 50 | return $this->command2string(Mailcode_Factory::showVar($variableName)); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param bool $highlighted |
| 33 | 33 | * @return Mailcode_Renderer |
| 34 | 34 | */ |
| 35 | - public function setOutputHighlighted(bool $highlighted=true) : Mailcode_Renderer |
|
| 35 | + public function setOutputHighlighted(bool $highlighted = true) : Mailcode_Renderer |
|
| 36 | 36 | { |
| 37 | 37 | $this->highlighted = $highlighted; |
| 38 | 38 | |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | return $this->command2string(Mailcode_Factory::setVarString($variableName, $value)); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function if(string $condition, string $type='') : string |
|
| 63 | + public function if (string $condition, string $type = '') : string |
|
| 64 | 64 | { |
| 65 | - return $this->command2string(Mailcode_Factory::if($condition, $type)); |
|
| 65 | + return $this->command2string(Mailcode_Factory::if ($condition, $type)); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public function ifVar(string $variable, string $operand, string $value, bool $quoteValue) : string |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | return $this->command2string(Mailcode_Factory::ifVarNotEqualsString($variable, $value)); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public function elseIf(string $condition, string $type='') : string |
|
| 98 | + public function elseIf (string $condition, string $type = '') : string |
|
| 99 | 99 | { |
| 100 | - return $this->command2string(Mailcode_Factory::elseIf($condition, $type)); |
|
| 100 | + return $this->command2string(Mailcode_Factory::elseIf ($condition, $type)); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | public function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue) : string |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | protected function command2string(Mailcode_Commands_Command $command) : string |
| 149 | 149 | { |
| 150 | - if($this->highlighted) |
|
| 150 | + if ($this->highlighted) |
|
| 151 | 151 | { |
| 152 | 152 | return $command->getHighlighted(); |
| 153 | 153 | } |
@@ -62,7 +62,9 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | public function if(string $condition, string $type='') : string |
| 64 | 64 | { |
| 65 | - return $this->command2string(Mailcode_Factory::if($condition, $type)); |
|
| 65 | + return $this->command2string(Mailcode_Factory::if($condition, $type) { |
|
| 66 | + ); |
|
| 67 | + } |
|
| 66 | 68 | } |
| 67 | 69 | |
| 68 | 70 | public function ifVar(string $variable, string $operand, string $value, bool $quoteValue) : string |
@@ -97,7 +99,9 @@ discard block |
||
| 97 | 99 | |
| 98 | 100 | public function elseIf(string $condition, string $type='') : string |
| 99 | 101 | { |
| 100 | - return $this->command2string(Mailcode_Factory::elseIf($condition, $type)); |
|
| 102 | + return $this->command2string(Mailcode_Factory::elseIf($condition, $type) { |
|
| 103 | + ); |
|
| 104 | + } |
|
| 101 | 105 | } |
| 102 | 106 | |
| 103 | 107 | public function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue) : string |
@@ -130,10 +134,12 @@ discard block |
||
| 130 | 134 | return $this->command2string(Mailcode_Factory::elseIfVarNotEqualsString($variable, $value)); |
| 131 | 135 | } |
| 132 | 136 | |
| 133 | - public function else() : string |
|
| 137 | + public function else { |
|
| 138 | + () : string |
|
| 134 | 139 | { |
| 135 | 140 | return $this->command2string(Mailcode_Factory::else()); |
| 136 | 141 | } |
| 142 | + } |
|
| 137 | 143 | |
| 138 | 144 | public function end() : string |
| 139 | 145 | { |