PDO4You\PDO4You::countWhere PHP Method

countWhere() private static method

Returns the sum of occurrences, in an array of a given condition satisfied
private static countWhere ( mixed $value = 1, string $operator = '==', string $conditional = 1 ) : integer
$value mixed The value or array to be evaluated
$operator string Operator of evaluation
$conditional string Conditional assignment
return integer
    private static function countWhere($value = 1, $operator = '==', $conditional = 1)
    {
        $array = is_array($value) ? $value : (array) $value;
        $operator = !in_array($operator, array('<', '>', '<=', '>=', '==', '!=')) ? '==' : $operator;
        $i = 0;
        foreach ($array as $current) {
            $match = null;
            eval('$match = (bool)("' . $current . '"' . $operator . '"' . $conditional . '");');
            $i = $match ? ++$i : $i;
        }
        return $i;
    }