| Total Complexity | 6 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Coverage | 93.33% |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | /** |
||
| 15 | * Class SimpleCondition represents a simple condition like `"column" operator value`. |
||
| 16 | */ |
||
| 17 | class SimpleCondition implements SimpleConditionInterface |
||
| 18 | { |
||
| 19 | public function __construct( |
||
| 20 | 251 | private string|array|ExpressionInterface $column, |
|
| 21 | private string $operator, |
||
| 22 | 251 | private array|int|string|Iterator|ExpressionInterface|null $value |
|
| 23 | 251 | ) { |
|
| 24 | 251 | } |
|
| 25 | 251 | ||
| 26 | public function getColumn(): string|array|ExpressionInterface |
||
| 27 | { |
||
| 28 | return $this->column; |
||
| 29 | } |
||
| 30 | 291 | ||
| 31 | public function getOperator(): string |
||
| 32 | 291 | { |
|
| 33 | return $this->operator; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function getValue(): array|int|string|Iterator|ExpressionInterface|null |
||
| 37 | { |
||
| 38 | 291 | return $this->value; |
|
| 39 | } |
||
| 40 | 291 | ||
| 41 | public static function fromArrayDefinition(string $operator, array $operands): self |
||
| 42 | { |
||
| 43 | if (count($operands) !== 2) { |
||
| 44 | throw new InvalidArgumentException("Operator '$operator' requires two operands."); |
||
| 45 | } |
||
| 46 | 291 | ||
| 47 | return new static($operands[0], $operator, $operands[1]); |
||
| 48 | 291 | } |
|
| 49 | } |
||
| 50 |