mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-30 19:50:12 +02:00
add pattern Interpreter
This commit is contained in:
20
Behavioral/Interpreter/AndExp.php
Normal file
20
Behavioral/Interpreter/AndExp.php
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user