protected static function ResourceFieldCollection::evaluateExpression in RESTful 7.2
Evaluate a simple expression.
Parameters
mixed $value1: The first value.
mixed $value2: The second value.
string $operator: The operator.
Return value
bool TRUE or FALSE based on the evaluated expression.
Throws
BadRequestException
File
- src/
Plugin/ resource/ Field/ ResourceFieldCollection.php, line 356 - Contains \Drupal\restful\Plugin\resource\Field\ResourceFieldCollection.
Class
Namespace
Drupal\restful\Plugin\resource\FieldCode
protected static function evaluateExpression($value1, $value2, $operator) {
switch ($operator) {
case '=':
return $value1 == $value2;
case '<':
return $value1 < $value2;
case '>':
return $value1 > $value2;
case '>=':
return $value1 >= $value2;
case '<=':
return $value1 <= $value2;
case '<>':
case '!=':
return $value1 != $value2;
case 'IN':
return in_array($value1, $value2);
case 'BETWEEN':
return $value1 >= $value2[0] && $value1 >= $value2[1];
}
return FALSE;
}