ValueExpression.class.php (828B)
1 <?php 2 3 namespace template_engine\element; 4 5 class ValueExpression 6 { 7 8 public $type; 9 public $name; 10 public $position; 11 12 const TYPE_DATA_VAR = 1; 13 const TYPE_MESSAGE = 2; 14 const TYPE_CONFIG = 3; 15 16 /** 17 * ValueExpression constructor. 18 * @param $type 19 * @param $name 20 * @param $position 21 */ 22 public function __construct($type, $name, $position) 23 { 24 $this->type = $type; 25 $this->name = $name; 26 $this->position = $position; 27 } 28 29 public function getAsString() { 30 switch($this->type) { 31 case ValueExpression::TYPE_CONFIG: 32 $ns = 'config:'; 33 break; 34 case ValueExpression::TYPE_MESSAGE: 35 $ns = 'message:'; 36 break; 37 case ValueExpression::TYPE_DATA_VAR: 38 default: 39 $ns = ''; 40 break; 41 } 42 return '$'.'{' . $ns . $this->name . '}'; 43 } 44 45 }