This commit is contained in:
Roman Martinuk
2021-04-13 00:29:24 +03:00
parent e31dbe5547
commit dea71e83b4
3 changed files with 4 additions and 17 deletions

View File

@@ -4,17 +4,12 @@ namespace DesignPatterns\Behavioral\Interpreter;
class AndExp extends AbstractExp
{
private AbstractExp $first;
private AbstractExp $second;
public function __construct(AbstractExp $first, AbstractExp $second)
public function __construct(private AbstractExp $first, private AbstractExp $second)
{
$this->first = $first;
$this->second = $second;
}
public function interpret(Context $context): bool
{
return (bool) $this->first->interpret($context) && $this->second->interpret($context);
return $this->first->interpret($context) && $this->second->interpret($context);
}
}

View File

@@ -4,13 +4,8 @@ namespace DesignPatterns\Behavioral\Interpreter;
class OrExp extends AbstractExp
{
private AbstractExp $first;
private AbstractExp $second;
public function __construct(AbstractExp $first, AbstractExp $second)
public function __construct(private AbstractExp $first, private AbstractExp $second)
{
$this->first = $first;
$this->second = $second;
}
public function interpret(Context $context): bool

View File

@@ -4,11 +4,8 @@ namespace DesignPatterns\Behavioral\Interpreter;
class VariableExp extends AbstractExp
{
private string $name;
public function __construct(string $name)
public function __construct(private string $name)
{
$this->name = $name;
}
public function interpret(Context $context): bool