| Total Complexity | 5 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | trait Mailcode_Traits_Commands_Validation_Variable |
||
| 26 | { |
||
| 27 | /** |
||
| 28 | * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL |
||
| 29 | */ |
||
| 30 | protected $variableToken; |
||
| 31 | |||
| 32 | protected function validateSyntax_variable() : void |
||
| 33 | { |
||
| 34 | $var = $this->validator->createVariable(); |
||
| 35 | |||
| 36 | if($var->isValid()) |
||
| 37 | { |
||
| 38 | $this->variableToken = $var->getToken(); |
||
| 39 | } |
||
| 40 | else |
||
| 41 | { |
||
| 42 | $this->validationResult->makeError( |
||
| 43 | t('No variable has been specified.'), |
||
| 44 | Mailcode_Commands_CommonConstants::VALIDATION_VARIABLE_MISSING |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Retrieves the variable being compared. |
||
| 51 | * |
||
| 52 | * @return Mailcode_Variables_Variable |
||
| 53 | */ |
||
| 54 | public function getVariable() : Mailcode_Variables_Variable |
||
| 55 | { |
||
| 56 | if($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
||
| 57 | { |
||
| 58 | return $this->variableToken->getVariable(); |
||
| 59 | } |
||
| 60 | |||
| 61 | throw new Mailcode_Exception( |
||
| 62 | 'No variable available', |
||
| 63 | null, |
||
| 64 | Mailcode_Commands_CommonConstants::ERROR_NO_VARIABLE_AVAILABLE |
||
| 65 | ); |
||
| 66 | } |
||
| 67 | |||
| 68 | public function getVariableName() : string |
||
| 71 | } |
||
| 72 | } |
||
| 73 |