| Total Complexity | 6 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | */ |
||
| 14 | class ExistsCondition implements ExistConditionInterface |
||
| 15 | { |
||
| 16 | public function __construct(private string $operator, private QueryInterface $query) |
||
| 17 | { |
||
| 18 | } |
||
| 19 | |||
| 20 | public function getOperator(): string |
||
| 21 | { |
||
| 22 | return $this->operator; |
||
| 23 | } |
||
| 24 | |||
| 25 | public function getQuery(): QueryInterface |
||
| 26 | { |
||
| 27 | return $this->query; |
||
| 28 | } |
||
| 29 | |||
| 30 | public static function fromArrayDefinition(string $operator, array $operands): self |
||
| 31 | { |
||
| 32 | if (!isset($operands[0]) || !$operands[0] instanceof QueryInterface) { |
||
| 33 | throw new InvalidArgumentException('Sub query for EXISTS operator must be a Query object.'); |
||
| 34 | } |
||
| 35 | |||
| 36 | return new static($operator, $operands[0]); |
||
| 37 | } |
||
| 38 | } |
||
| 39 |