diff options
Diffstat (limited to 'lib/exTpl/SymbolExpression.php')
| -rw-r--r-- | lib/exTpl/SymbolExpression.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/exTpl/SymbolExpression.php b/lib/exTpl/SymbolExpression.php new file mode 100644 index 0000000..178a51f --- /dev/null +++ b/lib/exTpl/SymbolExpression.php @@ -0,0 +1,39 @@ +<?php + +namespace exTpl; + +/** + * SymbolExpression represents a symbol (template variable). + */ +class SymbolExpression implements Expression +{ + protected string $name; + + /** + * Initializes a new Expression instance. + * + * @param string $name symbol name + */ + public function __construct(string $name) + { + $this->name = $name; + } + + /** + * Returns the name of this symbol. + */ + public function name(): string + { + return $this->name; + } + + /** + * Returns the value of this expression. + * + * @param Context $context symbol table + */ + public function value(Context $context): mixed + { + return $context->lookup($this->name); + } +} |
