| Total Complexity | 7 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Coverage | 94.44% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | * Class BetweenCondition represents a `BETWEEN` condition. |
||
| 13 | */ |
||
| 14 | class BetweenCondition implements BetweenConditionInterface |
||
| 15 | { |
||
| 16 | public function __construct( |
||
| 17 | private string|array|ExpressionInterface $column, |
||
| 18 | private string $operator, |
||
| 19 | 35 | private mixed $intervalStart, |
|
| 20 | private mixed $intervalEnd |
||
| 21 | 35 | ) { |
|
| 22 | 35 | } |
|
| 23 | 35 | ||
| 24 | 35 | public function getColumn(): string|array|ExpressionInterface |
|
| 25 | 35 | { |
|
| 26 | return $this->column; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function getIntervalEnd(): mixed |
||
| 30 | 35 | { |
|
| 31 | return $this->intervalEnd; |
||
| 32 | 35 | } |
|
| 33 | |||
| 34 | public function getIntervalStart(): mixed |
||
| 35 | { |
||
| 36 | return $this->intervalStart; |
||
| 37 | } |
||
| 38 | 35 | ||
| 39 | public function getOperator(): string |
||
| 40 | 35 | { |
|
| 41 | return $this->operator; |
||
| 42 | } |
||
| 43 | |||
| 44 | public static function fromArrayDefinition(string $operator, array $operands): self |
||
| 45 | { |
||
| 46 | 35 | if (!isset($operands[0], $operands[1], $operands[2])) { |
|
| 47 | throw new InvalidArgumentException("Operator '$operator' requires three operands."); |
||
| 48 | 35 | } |
|
| 49 | |||
| 50 | return new static($operands[0], $operator, $operands[1], $operands[2]); |
||
| 51 | } |
||
| 52 | } |
||
| 53 |