mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 14:03:27 +00:00
Simpler range AST constructors
This commit is contained in:
@@ -12,6 +12,26 @@ class RangeExpression extends Node
|
||||
private $higher_bound;
|
||||
private $higher_inclusive;
|
||||
|
||||
public static function lessThan(Field $field, $bound)
|
||||
{
|
||||
return new self($field, $bound, false);
|
||||
}
|
||||
|
||||
public static function lessThanOrEqual(Field $field, $bound)
|
||||
{
|
||||
return new self($field, $bound, true);
|
||||
}
|
||||
|
||||
public static function greaterThan(Field $field, $bound)
|
||||
{
|
||||
return new self($field, null, null, $bound, false);
|
||||
}
|
||||
|
||||
public static function greaterThanOrEqual(Field $field, $bound)
|
||||
{
|
||||
return new self($field, null, null, $bound, true);
|
||||
}
|
||||
|
||||
public function __construct(Field $field, $lb, $li = false, $hb = null, $hi = false)
|
||||
{
|
||||
$this->field = $field;
|
||||
|
@@ -137,13 +137,13 @@ class QueryVisitor implements Visit
|
||||
|
||||
switch ($node->getId()) {
|
||||
case NodeTypes::LT_EXPR:
|
||||
return new AST\RangeExpression($field, $expression, false);
|
||||
return AST\RangeExpression::lessThan($field, $expression);
|
||||
case NodeTypes::LTE_EXPR:
|
||||
return new AST\RangeExpression($field, $expression, true);
|
||||
return AST\RangeExpression::lessThanOrEqual($field, $expression);
|
||||
case NodeTypes::GT_EXPR:
|
||||
return new AST\RangeExpression($field, null, null, $expression, false);
|
||||
return AST\RangeExpression::greaterThan($field, $expression);
|
||||
case NodeTypes::GTE_EXPR:
|
||||
return new AST\RangeExpression($field, null, null, $expression, true);
|
||||
return AST\RangeExpression::greaterThanOrEqual($field, $expression);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user