| 1 | <?php |
||
| 10 | final class Query implements \Countable |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var array |
||
| 14 | */ |
||
| 15 | private $criteria = []; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Query constructor. |
||
| 19 | * @param array $criteria |
||
| 20 | */ |
||
| 21 | 13 | public function __construct(array $criteria = []) |
|
| 25 | |||
| 26 | /** |
||
| 27 | * @param CriterionInterface $criterion |
||
| 28 | * @return Query |
||
| 29 | */ |
||
| 30 | 3 | public function with(CriterionInterface $criterion): self |
|
| 31 | { |
||
| 32 | 3 | $clone = clone $this; |
|
| 33 | 3 | $clone->criteria[] = $criterion; |
|
| 34 | 3 | return $clone; |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @return string |
||
| 39 | */ |
||
| 40 | 6 | public function __toString(): string |
|
| 44 | |||
| 45 | /** |
||
| 46 | * @return int |
||
| 47 | */ |
||
| 48 | 7 | public function count() |
|
| 52 | } |