mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-06-22 09:13:53 +02:00
26 lines
418 B
PHP
26 lines
418 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;
|
|
}
|
|
}
|