You are here

protected function EntityFieldOperationCompareType::compareValue in Entity Field Condition 2.0.x

Compare the field value based on operation.

Parameters

mixed $field_value: The field value.

Return value

bool Return TRUE if the value is comparable; otherwise FALSE.

1 call to EntityFieldOperationCompareType::compareValue()
EntityFieldOperationCompareType::evaluate in src/Plugin/EntityFieldCondition/CompareType/EntityFieldOperationCompareType.php
Evaluate the entity field value.

File

src/Plugin/EntityFieldCondition/CompareType/EntityFieldOperationCompareType.php, line 101

Class

EntityFieldOperationCompareType
Define the entity field operation compare type plugin.

Namespace

Drupal\entity_field_condition\Plugin\EntityFieldCondition\CompareType

Code

protected function compareValue($field_value) : bool {
  $verdict = FALSE;
  $value = $this
    ->getValue();
  switch ($this
    ->getValueOperation()) {
    case '==':
      $verdict = $field_value == $value;
      break;
    case '===':
      $verdict = $field_value === $value;
      break;
    case '<':
      $verdict = $field_value < $value;
      break;
    case '<=':
      $verdict = $field_value <= $value;
      break;
    case '>':
      $verdict = $field_value > $value;
      break;
    case '>=':
      $verdict = $field_value >= $value;
      break;
  }
  return $verdict;
}