add pattern Interpreter

This commit is contained in:
Roman Martinuk
2021-03-14 18:40:48 +03:00
parent bd124378c5
commit af0fccfef3
7 changed files with 158 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
<?php declare(strict_types=1);
namespace DesignPatterns\Behavioral\Interpreter;
class AndExp extends AbstractExp
{
private AbstractExp $first;
private AbstractExp $second;
public function __construct(AbstractExp $first, AbstractExp $second)
{
$this->first = $first;
$this->second = $second;
}
public function interpret(Context $context): bool
{
return (bool) $this->first->interpret($context) && $this->second->interpret($context);
}
}