mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-06-06 05:55:09 +02:00
24 lines
417 B
PHP
24 lines
417 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace DesignPatterns\Behavioral\Interpreter;
|
|
|
|
/**
|
|
* This TerminalExpression
|
|
*/
|
|
class VariableExp extends AbstractExp
|
|
{
|
|
public function __construct(private string $name)
|
|
{
|
|
}
|
|
|
|
public function interpret(Context $context): bool
|
|
{
|
|
return $context->lookUp($this->name);
|
|
}
|
|
|
|
public function getName(): string
|
|
{
|
|
return $this->name;
|
|
}
|
|
}
|