function DataListCountIs::doEvaluate

Compare the value to the count of the list.

Parameters

array $list: The list to compare the value to.

string $operator: The type of comparison to do, may be one of '==', '<', or '>'.

int $value: The value of that the count is to compare to.

Return value

bool TRUE if the comparison returns true.

File

src/Plugin/Condition/DataListCountIs.php, line 52

Class

DataListCountIs
Provides a 'List count comparison' condition.

Namespace

Drupal\rules\Plugin\Condition

Code

protected function doEvaluate(array $list, $operator, $value) {
    switch ($operator) {
        case '==':
            return count($list) == $value;
        case '<':
            return count($list) < $value;
        case '<=':
            return count($list) <= $value;
        case '>':
            return count($list) > $value;
        case '>=':
            return count($list) >= $value;
    }
}