You are here

private function DataComparison::compare in Business Rules 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/BusinessRulesCondition/DataComparison.php \Drupal\business_rules\Plugin\BusinessRulesCondition\DataComparison::compare()

Compare 2 values.

Parameters

mixed $value: The First value.

mixed $compare: The second value.

string $operator: The operator.

Return value

bool The comparison result.

1 call to DataComparison::compare()
DataComparison::process in src/Plugin/BusinessRulesCondition/DataComparison.php
Process the condition.

File

src/Plugin/BusinessRulesCondition/DataComparison.php, line 158

Class

DataComparison
Class DataComparison.

Namespace

Drupal\business_rules\Plugin\BusinessRulesCondition

Code

private function compare($value, $compare, $operator) {
  if (isset($value['value'])) {
    $entity_value = strip_tags(strtolower(trim($value['value'])));
    $compare_value = strtolower(trim($compare));
    return $this->util
      ->criteriaMet($entity_value, $operator, $compare_value);
  }
  elseif (isset($value['target_id'])) {
    $entity_value = strip_tags(strtolower(trim($value['target_id'])));
    $compare_value = strtolower(trim($compare));
    return $this->util
      ->criteriaMet($entity_value, $operator, $compare_value);
  }
  else {
    return FALSE;
  }
}