@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $keywords = $command->getLogicKeywords()->getKeywords(); |
| 35 | 35 | |
| 36 | - foreach($keywords as $keyword) |
|
| 36 | + foreach ($keywords as $keyword) |
|
| 37 | 37 | { |
| 38 | 38 | $keyCommand = $keyword->getCommand(); |
| 39 | 39 | |
| 40 | - if($keyCommand instanceof Mailcode_Commands_IfBase) |
|
| 40 | + if ($keyCommand instanceof Mailcode_Commands_IfBase) |
|
| 41 | 41 | { |
| 42 | 42 | $body .= ' '.$this->getSign($keyword).' '.$this->translateBody($keyCommand); |
| 43 | 43 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | protected function getSign(Mailcode_Commands_LogicKeywords_Keyword $keyword) : string |
| 62 | 62 | { |
| 63 | - switch($keyword->getName()) |
|
| 63 | + switch ($keyword->getName()) |
|
| 64 | 64 | { |
| 65 | 65 | case 'and': |
| 66 | 66 | return '&&'; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | $sign = ''; |
| 85 | 85 | |
| 86 | - if($notEmpty) |
|
| 86 | + if ($notEmpty) |
|
| 87 | 87 | { |
| 88 | 88 | $sign = '!'; |
| 89 | 89 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | $params = $command->getParams(); |
| 101 | 101 | |
| 102 | - if(!$params) |
|
| 102 | + if (!$params) |
|
| 103 | 103 | { |
| 104 | 104 | return ''; |
| 105 | 105 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | protected function _translateContains(Mailcode_Variables_Variable $variable, bool $caseSensitive, string $searchTerm) : string |
| 121 | 121 | { |
| 122 | 122 | $opts = 's'; |
| 123 | - if($caseSensitive) |
|
| 123 | + if ($caseSensitive) |
|
| 124 | 124 | { |
| 125 | 125 | $opts = 'is'; |
| 126 | 126 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | protected function _translateSearch(string $mode, Mailcode_Variables_Variable $variable, bool $caseSensitive, string $searchTerm) : string |
| 137 | 137 | { |
| 138 | 138 | $method = $mode.'With'; |
| 139 | - if($caseSensitive) |
|
| 139 | + if ($caseSensitive) |
|
| 140 | 140 | { |
| 141 | 141 | $method = $mode.'WithIgnoreCase'; |
| 142 | 142 | } |
@@ -32,37 +32,37 @@ |
||
| 32 | 32 | |
| 33 | 33 | protected function translateBody(Mailcode_Commands_IfBase $command) : string |
| 34 | 34 | { |
| 35 | - if($command instanceof Mailcode_Commands_Command_If_Command) |
|
| 35 | + if ($command instanceof Mailcode_Commands_Command_If_Command) |
|
| 36 | 36 | { |
| 37 | 37 | return $this->translateCommand($command); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 40 | + if ($command instanceof Mailcode_Commands_Command_If_Variable) |
|
| 41 | 41 | { |
| 42 | 42 | return $this->translateVariable($command); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if($command instanceof Mailcode_Commands_Command_If_Contains) |
|
| 45 | + if ($command instanceof Mailcode_Commands_Command_If_Contains) |
|
| 46 | 46 | { |
| 47 | 47 | return $this->translateContains($command); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if($command instanceof Mailcode_Commands_Command_If_Empty) |
|
| 50 | + if ($command instanceof Mailcode_Commands_Command_If_Empty) |
|
| 51 | 51 | { |
| 52 | 52 | return $this->translateEmpty($command); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if($command instanceof Mailcode_Commands_Command_If_NotEmpty) |
|
| 55 | + if ($command instanceof Mailcode_Commands_Command_If_NotEmpty) |
|
| 56 | 56 | { |
| 57 | 57 | return $this->translateNotEmpty($command); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if($command instanceof Mailcode_Commands_Command_If_BeginsWith) |
|
| 60 | + if ($command instanceof Mailcode_Commands_Command_If_BeginsWith) |
|
| 61 | 61 | { |
| 62 | 62 | return $this->translateBeginsWith($command); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if($command instanceof Mailcode_Commands_Command_If_EndsWith) |
|
| 65 | + if ($command instanceof Mailcode_Commands_Command_If_EndsWith) |
|
| 66 | 66 | { |
| 67 | 67 | return $this->translateEndsWith($command); |
| 68 | 68 | } |
@@ -32,37 +32,37 @@ |
||
| 32 | 32 | |
| 33 | 33 | protected function translateBody(Mailcode_Commands_IfBase $command) : string |
| 34 | 34 | { |
| 35 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Command) |
|
| 35 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Command) |
|
| 36 | 36 | { |
| 37 | 37 | return $this->translateCommand($command); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 40 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Variable) |
|
| 41 | 41 | { |
| 42 | 42 | return $this->translateVariable($command); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Contains) |
|
| 45 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Contains) |
|
| 46 | 46 | { |
| 47 | 47 | return $this->translateContains($command); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if($command instanceof Mailcode_Commands_Command_ElseIf_Empty) |
|
| 50 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_Empty) |
|
| 51 | 51 | { |
| 52 | 52 | return $this->translateEmpty($command); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if($command instanceof Mailcode_Commands_Command_ElseIf_NotEmpty) |
|
| 55 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_NotEmpty) |
|
| 56 | 56 | { |
| 57 | 57 | return $this->translateNotEmpty($command); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if($command instanceof Mailcode_Commands_Command_ElseIf_BeginsWith) |
|
| 60 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_BeginsWith) |
|
| 61 | 61 | { |
| 62 | 62 | return $this->translateBeginsWith($command); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if($command instanceof Mailcode_Commands_Command_ElseIf_EndsWith) |
|
| 65 | + if ($command instanceof Mailcode_Commands_Command_ElseIf_EndsWith) |
|
| 66 | 66 | { |
| 67 | 67 | return $this->translateEndsWith($command); |
| 68 | 68 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param string $formatString A date format string, or empty string for default. |
| 48 | 48 | * @return Mailcode_Commands_Command_ShowDate |
| 49 | 49 | */ |
| 50 | - public static function showDate(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowDate |
|
| 50 | + public static function showDate(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowDate |
|
| 51 | 51 | { |
| 52 | 52 | return self::$commandSets->show()->showDate($variableName, $formatString); |
| 53 | 53 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
| 76 | 76 | */ |
| 77 | - public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable |
|
| 77 | + public static function setVar(string $variableName, string $value, bool $quoteValue = true) : Mailcode_Commands_Command_SetVariable |
|
| 78 | 78 | { |
| 79 | 79 | return self::$commandSets->set()->setVar($variableName, $value, $quoteValue); |
| 80 | 80 | } |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | return self::$commandSets->if()->end(); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public static function if(string $condition, string $type='') : Mailcode_Commands_Command_If |
|
| 110 | + public static function if (string $condition, string $type = '') : Mailcode_Commands_Command_If |
|
| 111 | 111 | { |
| 112 | 112 | return self::$commandSets->if()->if($condition, $type); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable |
|
| 115 | + public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable |
|
| 116 | 116 | { |
| 117 | 117 | return self::$commandSets->if()->ifVar($variable, $operand, $value, $quoteValue); |
| 118 | 118 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | return self::$commandSets->if()->ifVarString($variable, $operand, $value); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - public static function ifVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable |
|
| 125 | + public static function ifVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable |
|
| 126 | 126 | { |
| 127 | 127 | return self::$commandSets->if()->ifVarEquals($variable, $value, $quoteValue); |
| 128 | 128 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | return self::$commandSets->if()->ifVarEqualsString($variable, $value); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If_Variable |
|
| 135 | + public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If_Variable |
|
| 136 | 136 | { |
| 137 | 137 | return self::$commandSets->if()->ifVarNotEquals($variable, $value, $quoteValue); |
| 138 | 138 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | return self::$commandSets->if()->ifVarNotEqualsString($variable, $value); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public static function elseIf(string $condition, string $type='') : Mailcode_Commands_Command_ElseIf |
|
| 145 | + public static function elseIf (string $condition, string $type = '') : Mailcode_Commands_Command_ElseIf |
|
| 146 | 146 | { |
| 147 | 147 | return self::$commandSets->elseIf()->elseIf($condition, $type); |
| 148 | 148 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | return self::$commandSets->elseIf()->elseIfNotEmpty($variable); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable |
|
| 160 | + public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable |
|
| 161 | 161 | { |
| 162 | 162 | return self::$commandSets->elseIf()->elseIfVar($variable, $operand, $value, $quoteValue); |
| 163 | 163 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | return self::$commandSets->elseIf()->elseIfVarString($variable, $operand, $value); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable |
|
| 170 | + public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable |
|
| 171 | 171 | { |
| 172 | 172 | return self::$commandSets->elseIf()->elseIfVarEquals($variable, $value, $quoteValue); |
| 173 | 173 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | return self::$commandSets->elseIf()->elseIfVarEqualsString($variable, $value); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf_Variable |
|
| 180 | + public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf_Variable |
|
| 181 | 181 | { |
| 182 | 182 | return self::$commandSets->elseIf()->elseIfVarNotEquals($variable, $value, $quoteValue); |
| 183 | 183 | } |
@@ -187,32 +187,32 @@ discard block |
||
| 187 | 187 | return self::$commandSets->elseIf()->elseIfVarNotEqualsString($variable, $value); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - public static function ifBeginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_BeginsWith |
|
| 190 | + public static function ifBeginsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_BeginsWith |
|
| 191 | 191 | { |
| 192 | 192 | return self::$commandSets->if()->ifBeginsWith($variable, $search, $caseInsensitive); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - public static function ifEndsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_EndsWith |
|
| 195 | + public static function ifEndsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_EndsWith |
|
| 196 | 196 | { |
| 197 | 197 | return self::$commandSets->if()->ifEndsWith($variable, $search, $caseInsensitive); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - public static function elseIfBeginsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_BeginsWith |
|
| 200 | + public static function elseIfBeginsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_BeginsWith |
|
| 201 | 201 | { |
| 202 | 202 | return self::$commandSets->elseIf()->elseIfBeginsWith($variable, $search, $caseInsensitive); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - public static function elseIfEndsWith(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_EndsWith |
|
| 205 | + public static function elseIfEndsWith(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_EndsWith |
|
| 206 | 206 | { |
| 207 | 207 | return self::$commandSets->elseIf()->elseIfEndsWith($variable, $search, $caseInsensitive); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - public static function ifContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_If_Contains |
|
| 210 | + public static function ifContains(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_If_Contains |
|
| 211 | 211 | { |
| 212 | 212 | return self::$commandSets->if()->ifContains($variable, $search, $caseInsensitive); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - public static function elseIfContains(string $variable, string $search, bool $caseInsensitive=false) : Mailcode_Commands_Command_ElseIf_Contains |
|
| 215 | + public static function elseIfContains(string $variable, string $search, bool $caseInsensitive = false) : Mailcode_Commands_Command_ElseIf_Contains |
|
| 216 | 216 | { |
| 217 | 217 | return self::$commandSets->elseIf()->elseIfContains($variable, $search, $caseInsensitive); |
| 218 | 218 | } |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | public static function init() : void |
| 264 | 264 | { |
| 265 | - if(!isset(self::$commandSets)) |
|
| 265 | + if (!isset(self::$commandSets)) |
|
| 266 | 266 | { |
| 267 | 267 | self::$commandSets = new Mailcode_Factory_CommandSets(); |
| 268 | 268 | } |
@@ -25,24 +25,24 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | const ERROR_PLACEHOLDER_TOO_LONG = 47901; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var int |
|
| 30 | - */ |
|
| 28 | + /** |
|
| 29 | + * @var int |
|
| 30 | + */ |
|
| 31 | 31 | protected $id; |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var Mailcode_Parser_Safeguard |
|
| 35 | - */ |
|
| 33 | + /** |
|
| 34 | + * @var Mailcode_Parser_Safeguard |
|
| 35 | + */ |
|
| 36 | 36 | protected $safeguard; |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var Mailcode_Commands_Command |
|
| 40 | - */ |
|
| 38 | + /** |
|
| 39 | + * @var Mailcode_Commands_Command |
|
| 40 | + */ |
|
| 41 | 41 | protected $command; |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var string |
|
| 45 | - */ |
|
| 43 | + /** |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | 46 | protected $replacement = ''; |
| 47 | 47 | |
| 48 | 48 | public function __construct(int $id, Mailcode_Commands_Command $command, Mailcode_Parser_Safeguard $safeguard) |
@@ -115,18 +115,18 @@ discard block |
||
| 115 | 115 | return $this->command; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Serializes the placeholder's information into |
|
| 120 | - * an array with the following keys: |
|
| 121 | - * |
|
| 122 | - * - originalText |
|
| 123 | - * - replacementText |
|
| 124 | - * - normalizedText |
|
| 125 | - * - length |
|
| 126 | - * - id |
|
| 127 | - * |
|
| 128 | - * @return array<string,string|integer> |
|
| 129 | - */ |
|
| 118 | + /** |
|
| 119 | + * Serializes the placeholder's information into |
|
| 120 | + * an array with the following keys: |
|
| 121 | + * |
|
| 122 | + * - originalText |
|
| 123 | + * - replacementText |
|
| 124 | + * - normalizedText |
|
| 125 | + * - length |
|
| 126 | + * - id |
|
| 127 | + * |
|
| 128 | + * @return array<string,string|integer> |
|
| 129 | + */ |
|
| 130 | 130 | public function serialize() : array |
| 131 | 131 | { |
| 132 | 132 | return array( |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | class Mailcode_Parser_Statement_Validator |
| 30 | 30 | { |
| 31 | - /** |
|
| 32 | - * @var Mailcode_Parser_Statement |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var Mailcode_Parser_Statement |
|
| 33 | + */ |
|
| 34 | 34 | private $statement; |
| 35 | 35 | |
| 36 | 36 | public function __construct(Mailcode_Parser_Statement $statement) |
@@ -38,12 +38,12 @@ discard block |
||
| 38 | 38 | $this->statement = $statement; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Creates a variable validator: checks whether a single |
|
| 43 | - * variable token is present in the parameters. |
|
| 44 | - * |
|
| 45 | - * @return Mailcode_Parser_Statement_Validator_Type_Variable |
|
| 46 | - */ |
|
| 41 | + /** |
|
| 42 | + * Creates a variable validator: checks whether a single |
|
| 43 | + * variable token is present in the parameters. |
|
| 44 | + * |
|
| 45 | + * @return Mailcode_Parser_Statement_Validator_Type_Variable |
|
| 46 | + */ |
|
| 47 | 47 | public function createVariable() : Mailcode_Parser_Statement_Validator_Type_Variable |
| 48 | 48 | { |
| 49 | 49 | $validate = new Mailcode_Parser_Statement_Validator_Type_Variable($this->statement); |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | return $validate; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Creates a keyword validator: checks whether a single |
|
| 56 | - * keyword token is present in the parameters. |
|
| 57 | - * |
|
| 58 | - * @param string $keywordName |
|
| 59 | - * @return Mailcode_Parser_Statement_Validator_Type_Keyword |
|
| 60 | - */ |
|
| 54 | + /** |
|
| 55 | + * Creates a keyword validator: checks whether a single |
|
| 56 | + * keyword token is present in the parameters. |
|
| 57 | + * |
|
| 58 | + * @param string $keywordName |
|
| 59 | + * @return Mailcode_Parser_Statement_Validator_Type_Keyword |
|
| 60 | + */ |
|
| 61 | 61 | public function createKeyword(string $keywordName) : Mailcode_Parser_Statement_Validator_Type_Keyword |
| 62 | 62 | { |
| 63 | 63 | $validate = new Mailcode_Parser_Statement_Validator_Type_Keyword( |
@@ -82,11 +82,11 @@ |
||
| 82 | 82 | return $validate; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function createOperand(string $sign='') : Mailcode_Parser_Statement_Validator_Type_Operand |
|
| 85 | + public function createOperand(string $sign = '') : Mailcode_Parser_Statement_Validator_Type_Operand |
|
| 86 | 86 | { |
| 87 | 87 | $validate = new Mailcode_Parser_Statement_Validator_Type_Operand($this->statement); |
| 88 | 88 | |
| 89 | - if(!empty($sign)) |
|
| 89 | + if (!empty($sign)) |
|
| 90 | 90 | { |
| 91 | 91 | $validate->setOperandSign($sign); |
| 92 | 92 | } |
@@ -22,53 +22,53 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | const VALIDATION_ERROR_COMMAND_WITHOUT_PARAMETERS = 62401; |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var integer |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var integer |
|
| 27 | + */ |
|
| 28 | 28 | protected $searchIndex = -1; |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var Mailcode_Parser_Statement_Tokenizer_Token|NULL |
|
| 32 | - */ |
|
| 30 | + /** |
|
| 31 | + * @var Mailcode_Parser_Statement_Tokenizer_Token|NULL |
|
| 32 | + */ |
|
| 33 | 33 | protected $token; |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Retrieves the class name of the token type to |
|
| 37 | - * limit the token search to. Only a token of this |
|
| 38 | - * type will be stored. |
|
| 39 | - * |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 35 | + /** |
|
| 36 | + * Retrieves the class name of the token type to |
|
| 37 | + * limit the token search to. Only a token of this |
|
| 38 | + * type will be stored. |
|
| 39 | + * |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | 42 | abstract protected function getTokenClass() : string; |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Allows the validator to apply custom search |
|
| 46 | - * criteria to the tokens that are searched |
|
| 47 | - * through to find the target token. |
|
| 48 | - * |
|
| 49 | - * NOTE: Should return true if there are no |
|
| 50 | - * custom criteria to apply. |
|
| 51 | - * |
|
| 52 | - * @param Mailcode_Parser_Statement_Tokenizer_Token $token |
|
| 53 | - * @return bool |
|
| 54 | - */ |
|
| 44 | + /** |
|
| 45 | + * Allows the validator to apply custom search |
|
| 46 | + * criteria to the tokens that are searched |
|
| 47 | + * through to find the target token. |
|
| 48 | + * |
|
| 49 | + * NOTE: Should return true if there are no |
|
| 50 | + * custom criteria to apply. |
|
| 51 | + * |
|
| 52 | + * @param Mailcode_Parser_Statement_Tokenizer_Token $token |
|
| 53 | + * @return bool |
|
| 54 | + */ |
|
| 55 | 55 | abstract protected function _isMatch(Mailcode_Parser_Statement_Tokenizer_Token $token) : bool; |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @return Mailcode_Parser_Statement_Tokenizer_Token |
|
| 59 | - */ |
|
| 57 | + /** |
|
| 58 | + * @return Mailcode_Parser_Statement_Tokenizer_Token |
|
| 59 | + */ |
|
| 60 | 60 | abstract public function getToken(); |
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Checks if the specified token matches the current |
|
| 64 | - * search criteria (index, type...). If the token is |
|
| 65 | - * a match, the `_isMatch()` method is called to allow |
|
| 66 | - * the validator class to apply some custom criteria. |
|
| 67 | - * |
|
| 68 | - * @param Mailcode_Parser_Statement_Tokenizer_Token $token |
|
| 69 | - * @param int $index |
|
| 70 | - * @return bool |
|
| 71 | - */ |
|
| 62 | + /** |
|
| 63 | + * Checks if the specified token matches the current |
|
| 64 | + * search criteria (index, type...). If the token is |
|
| 65 | + * a match, the `_isMatch()` method is called to allow |
|
| 66 | + * the validator class to apply some custom criteria. |
|
| 67 | + * |
|
| 68 | + * @param Mailcode_Parser_Statement_Tokenizer_Token $token |
|
| 69 | + * @param int $index |
|
| 70 | + * @return bool |
|
| 71 | + */ |
|
| 72 | 72 | protected function isMatch(Mailcode_Parser_Statement_Tokenizer_Token $token, int $index) : bool |
| 73 | 73 | { |
| 74 | 74 | // filter out tokens of other types |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | return $this->_isMatch($token); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Attempts to find a token in the statement |
|
| 90 | - * that matches the current criteria, and the |
|
| 91 | - * first one it finds is returned. |
|
| 92 | - * |
|
| 93 | - * @return Mailcode_Parser_Statement_Tokenizer_Token|NULL |
|
| 94 | - */ |
|
| 88 | + /** |
|
| 89 | + * Attempts to find a token in the statement |
|
| 90 | + * that matches the current criteria, and the |
|
| 91 | + * first one it finds is returned. |
|
| 92 | + * |
|
| 93 | + * @return Mailcode_Parser_Statement_Tokenizer_Token|NULL |
|
| 94 | + */ |
|
| 95 | 95 | protected function findToken() : ?Mailcode_Parser_Statement_Tokenizer_Token |
| 96 | 96 | { |
| 97 | 97 | $tokens = $this->params->getTokens(); |
@@ -120,14 +120,14 @@ discard block |
||
| 120 | 120 | return false; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Searches for a specific token index. |
|
| 125 | - * |
|
| 126 | - * NOTE: only relevant when trying to find a single token. |
|
| 127 | - * |
|
| 128 | - * @param int $index |
|
| 129 | - * @return $this |
|
| 130 | - */ |
|
| 123 | + /** |
|
| 124 | + * Searches for a specific token index. |
|
| 125 | + * |
|
| 126 | + * NOTE: only relevant when trying to find a single token. |
|
| 127 | + * |
|
| 128 | + * @param int $index |
|
| 129 | + * @return $this |
|
| 130 | + */ |
|
| 131 | 131 | public function setIndex(int $index) : Mailcode_Parser_Statement_Validator_TokenType |
| 132 | 132 | { |
| 133 | 133 | $this->searchIndex = $index; |
@@ -72,12 +72,12 @@ discard block |
||
| 72 | 72 | protected function isMatch(Mailcode_Parser_Statement_Tokenizer_Token $token, int $index) : bool |
| 73 | 73 | { |
| 74 | 74 | // filter out tokens of other types |
| 75 | - if(!is_a($token, $this->getTokenClass())) |
|
| 75 | + if (!is_a($token, $this->getTokenClass())) |
|
| 76 | 76 | { |
| 77 | 77 | return false; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if($this->searchIndex >= 0 && $index !== $this->searchIndex) |
|
| 80 | + if ($this->searchIndex >= 0 && $index !== $this->searchIndex) |
|
| 81 | 81 | { |
| 82 | 82 | return false; |
| 83 | 83 | } |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | $tokens = $this->params->getTokens(); |
| 98 | 98 | |
| 99 | - foreach($tokens as $index => $token) |
|
| 99 | + foreach ($tokens as $index => $token) |
|
| 100 | 100 | { |
| 101 | - if($this->isMatch($token, $index)) |
|
| 101 | + if ($this->isMatch($token, $index)) |
|
| 102 | 102 | { |
| 103 | 103 | return $token; |
| 104 | 104 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | { |
| 112 | 112 | $token = $this->findToken(); |
| 113 | 113 | |
| 114 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token && is_a($token, $this->getTokenClass())) |
|
| 114 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token && is_a($token, $this->getTokenClass())) |
|
| 115 | 115 | { |
| 116 | 116 | $this->token = $token; |
| 117 | 117 | return true; |
@@ -20,9 +20,9 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | abstract class Mailcode_Parser_Statement_Validator_Type |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var Mailcode_Parser_Statement |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var Mailcode_Parser_Statement |
|
| 25 | + */ |
|
| 26 | 26 | protected $statement; |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | protected $params; |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var boolean |
|
| 35 | - */ |
|
| 33 | + /** |
|
| 34 | + * @var boolean |
|
| 35 | + */ |
|
| 36 | 36 | private $valid = true; |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var boolean |
|
| 40 | - */ |
|
| 38 | + /** |
|
| 39 | + * @var boolean |
|
| 40 | + */ |
|
| 41 | 41 | private $validated = false; |
| 42 | 42 | |
| 43 | 43 | public function __construct(Mailcode_Parser_Statement $statement) |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @return $this |
|
| 58 | - */ |
|
| 56 | + /** |
|
| 57 | + * @return $this |
|
| 58 | + */ |
|
| 59 | 59 | public function validate() : Mailcode_Parser_Statement_Validator_Type |
| 60 | 60 | { |
| 61 | 61 | if(!$this->validated) |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | */ |
| 59 | 59 | public function validate() : Mailcode_Parser_Statement_Validator_Type |
| 60 | 60 | { |
| 61 | - if(!$this->validated) |
|
| 61 | + if (!$this->validated) |
|
| 62 | 62 | { |
| 63 | 63 | $this->valid = $this->_validate(); |
| 64 | 64 | $this->validated = true; |
@@ -22,10 +22,10 @@ |
||
| 22 | 22 | { |
| 23 | 23 | const ERROR_NO_KEYWORD_TOKEN_FOUND = 62701; |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * The name of the keyword, with ":" appended. |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 25 | + /** |
|
| 26 | + * The name of the keyword, with ":" appended. |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | 29 | protected $keywordName; |
| 30 | 30 | |
| 31 | 31 | public function __construct(Mailcode_Parser_Statement $statement, string $keywordName) |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | public function getToken() : Mailcode_Parser_Statement_Tokenizer_Token_Keyword |
| 52 | 52 | { |
| 53 | - if($this->token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 53 | + if ($this->token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 54 | 54 | { |
| 55 | 55 | return $this->token; |
| 56 | 56 | } |