Number of elements true for the condition.

@param callable $condition Condition to check.
@return int
778057
protected function count_while_true( $condition ) {
		$count = 0;

		foreach ( $this->elements as $element ) {
			if ( ! $condition($element) ) {
				break;
			}
			$count++;
		}

		return $count;
	}
1202478
public function first(callable $conditions = null)
    {
        $array = $this->convertArray($this);

        if ($conditions) {
            foreach ($array as $key => $value) {
                if ($conditions($value, $key)) {
                    return $value;
                }
            }

            return null;
        }

        return $array[array_key_first($array)];
    }
1222579
public function filter( $condition ) {
		$elements = array();

		foreach ( $this->elements as $element ) {
			if ( call_user_func( $condition, $element ) ) {
				$elements[] = $element;
			}
		}

		return $this->new_from_trusted( $elements );
	}
1342187
public function count($condition = null, $params = null, $distinct=false) {
		if ($condition) {
			$this->driver->where($condition, $params);
		}
		return $this->driver->count($distinct);
	}
144101
public function countElementsBy($by, $value)
    {
        try {
            return count(
                $this->elements(
                    $this->using($by . ' selector')->value($value)
                )
            );
        } catch(\Exception $exception) {
            return 0;
        }
    }
1127462
protected function evaluate($condition)
    {
        if (null === $condition || false === $condition) {
            return false;
        }

        if (!is_string($condition)) {
            return false;
        }

        $condition = trim($condition);

        if (!strlen($condition)) {
            return false;
        }

        $config = $this->getConfig();

        if (0 < preg_match_all('/\$\\{\\s*([a-z0-9_\.]+)\\s*\\}/', $condition, $matches)) {
            foreach ($matches[0] as $i => $match) {
                $v = $config->get($matches[1][$i], null);
                $condition = str_replace($match, null === $v ? '""' : (is_numeric($v) ? $v : ('"'.str_replace('"', '\\"', (string) $v).'"')), $condition);
            }
        }

        $condition = trim($condition);

        if (0 < preg_match_all('/\%\\{\\s*([a-z0-9_]+)\\s*\\}/i', $condition, $matches)) {
            foreach ($matches[0] as $i => $match) {
                $v = getenv($matches[1][$i]);
                switch (true) {
                    case 'false' === ((string) $v):
                        $v = false;
                        break;
                    case 'true' === ((string) $v):
                        $v = true;
                        break;
                    case '1' === ((string) $v):
                        $v = 1;
                        break;
                    case false === $v:
                        $v = null;
                        break;
                    case null === $v:
                        $v = null;
                        break;
                    default:
                        if (!is_numeric($v)) {
                            $v = trim((string) $v);
                        }
                        break;
                }
                $condition = str_replace($match, null === $v ? '""' : (is_numeric($v) ? $v : ('"'.str_replace('"', '\\"', (string) $v).'"')), $condition);
            }
        }

        return $this->getExpressionService()->evaluate($condition, ['cfg' => $config]);
    }
609630
public function count(string $condition = '', array $params = array()) {
        $this->model->builder->select('COUNT(*)')
            ->from($this->model->tableName);
        if ($condition) {
            $this->model->builder->where($condition, $params);
        }
        $r = $this->model->builder->query();
        if (!is_array($r) || 0 === count($r)) {
            return false;
        }
        return (int) reset($r[0]);
    }
356929
public function id(array $condition)
    {
        $user_id = $this->user->getId();
        return $this->compare($user_id, $condition['value'], $condition['operator']);
    }
747332
protected function validateCondition($condition)
    {
        $condition = trim(strtolower($condition));

        if ('and' !== $condition && 'or' !== $condition) {
            throw new \Exception("Condition can only be one of: 'and', 'or'.");
        }

        return $condition;
    }
648852
public static function countByAttributes($attributes, $condition = null, $params = array())
    {
        if (!is_a($condition, '\\mpf\\datasources\\sql\\ModelCondition')) {
            $condition = ModelCondition::getFrom($condition, get_called_class());
        }
        /* @var $condition ModelCondition */
        foreach ($attributes as $column => $value) {
            $condition->compareColumn($column, $value);
        }
        return static::count($condition, $params);
    }
282628
protected function resolveConditionalLogic($condition)
    {
        if (is_callable([ $this, $condition ])) {
            return !!$this->{$condition}();
        } elseif (is_callable($condition)) {
            return !!$condition();
        } elseif ($this->view()) {
            return !!$this->renderTemplate($condition);
        }

        return !!$condition;
    }
1315227
public function count($count = false): int
    {
        // 如果不传递参数,返回记录总数
        if ($count === false) {
            return $this->count;
        }

        // 记录总数
        $this->count = intval($count);

        // 计算总页数
        $this->allPage = ceil($count / $this->size);

        // 调整当前页数,不能大于总页数
        $this->page = max(1, min($this->page, $this->allPage));

        return $this->count;
    }
561945
public function removeCondition($condition)
    {
        if ($this->conditions->contains($condition)) {
            $this->conditions->removeElement($condition);
        }

        return $this;
    }
629091
public function count(): int
    {
        $args = [];
        $methodName = __FUNCTION__;

        return (int) $this->findAndCall($methodName, $args);
    }
1217526
public static function counts($condition = null, $params = null, $distinct=false) {
        return static::dao()->count(
            $condition,
            $params,
            $distinct
        );
    }
278198
protected function applyRootCondition(&$condition)
    {
        if (false !== $this->rootAttribute) {
            $condition[] = [$this->rootAttribute => $this->node->{$this->rootAttribute}];
        }
    }
998768
private function checkCount(){
        $cnt = (int) $this->getMaxEntries();
        if ($cnt !== NULL && count($this->values) !== $cnt){
            trigger_error("Wrong count of Elements. Expected are $cnt. But right now there are ". count($this->values));
        }

    }