You are here

protected function RestfulDataProviderCToolsPlugins::evaluateExpression in RESTful 7

Evaluate a simple expression.

Parameters

$value1: The first value.

$value2: The second value.

$operator: The operator.

Return value

bool TRUE or FALSE based on the evaluated expression.

Throws

RestfulBadRequestException

1 call to RestfulDataProviderCToolsPlugins::evaluateExpression()
RestfulDataProviderCToolsPlugins::getPluginsSortedAndFiltered in plugins/restful/RestfulDataProviderCToolsPlugins.php
Gets the plugins filtered and sorted by the request.

File

plugins/restful/RestfulDataProviderCToolsPlugins.php, line 145
Contains \RestfulDataProviderCToolsPlugins

Class

RestfulDataProviderCToolsPlugins
@file Contains \RestfulDataProviderCToolsPlugins

Code

protected 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];
  }
}