<?php
declare(strict_types=1);
namespace League\CommonMark\Node;
use League\CommonMark\Node\Query\AndExpr;
use League\CommonMark\Node\Query\OrExpr;
final class Query
{
private $condition;
public function __construct()
{
$this->condition = new AndExpr();
}
public function where(callable ...$conditions): self
{
return $this->andWhere(...$conditions);
}
public function andWhere(callable ...$conditions): self
{
if ($this->condition instanceof AndExpr) {
foreach ($conditions as $condition) {
$this->condition->add($condition);
}
} else {
$this->condition = new AndExpr($this->condition, ...$conditions);
}
return $this;
}