Checks if value has an exact count

@param mixed $value The value
@param int   $count The count

@return bool
974444
public static function exactCount($value, int $count): bool
    {
        if (!static::isCountable($value)) {
            return false;
        }

        return count($value) == $count;
    }
5090
public function countValue($value)
    {
        $count = 0;
        foreach ($this->source as $arrayVal) {
            if ($arrayVal === $value) {
                ++$count;
            }
        }

        return $count;
    }
1203077
public function checkWords($value, $count)
    {
        if (!Type::isStringLike($value)) {
            return $count == 0;
        }

        return count(preg_split('~[^\p{L}\p{N}\']+~u', $value, -1, PREG_SPLIT_NO_EMPTY)) == $count;
    }
77316
public static function isFiniteNumber($value)
    {
        if (!(is_int($value) || is_float($value))) {
            return false;
        }

        if (is_nan($value) || is_infinite($value)) {
            return false;
        }

        if (abs($value) > pow(2, 53)) {
            return false;
        }

        return true;
    }
7394
protected function isValueSelected($value)
	{
		$val = $this->getValue();
		if (is_null($value)) {
			return FALSE;
		}
		elseif (is_array($val)) {
			return in_array($value, $val);
		}

		return $value == $val;
	}
1362514
protected function hasValue($value)
    {
        $value = (int) $value;

        return isset(static::$names[$value]) || array_key_exists($value, static::$names);
    }
1063447
private function hasValueInCustomerSection($value)
    {
        $customerText = $this->getElement('customer')->getText();

        return stripos($customerText, $value) !== false;
    }
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;
    }
199961
public static function plural($value, $count = 2)
    {
        if (($count === 1) || static::uncountable($value)) {
            return $value;
        }

        $plural = Inflector::pluralize($value);

        return static::matchCase($plural, $value);
    }
84834
public static function maxCount($value, int $maxCount): bool
    {
        if (!static::isCountable($value)) {
            return false;
        }

        return count($value) <= $maxCount;
    }
1173614
protected function isSequence($value)
    {
        if (!Helper::isSequential($value)) {
            return false;
        }

        if ($value === []) {
            return true;
        }

        $i=0;

        $lastItemType = null;

        foreach ($value as $key=>$item) {

            if ($key !== $i) {
                return false;
            }

            $itemType = Type::of($item);

            // TODO: list could be typed by common class or interface
            if ($i !== 0 && $itemType != $lastItemType) {
                return false;
            }

            $lastItemType = $itemType;
            $i++;
        }

        return true;

    }
407938
public function checkRequired($value)
    {
        if (is_null($value)) {
            return false;
        }

        if (is_string($value) && trim($value) === '') {
            return false;
        }

        if ((is_array($value) || $value instanceof Countable) && count($value) < 1) {
            return false;
        }

        return true;
    }
303062
public function skip($count = 1)
    {
        for ($i = $count; $this->valid() && $i > 0; $i--) {
            $this->next();
        }

        return $this->valid();
    }
531474
public function count($count = null)
    {
        if ($count === null) {
            return isset($this->options['count']) ? $this->options['count'] : 0;
        } else {
            $this->options['count'] = $count;
            return $this;
        }
    }
566457
public function validateCount($value, array $context) {
		$maxWorkers = Config::maxworkers();
		if (!$value || !$maxWorkers) {
			return true;
		}

		$currentWorkers = $this->find()->where(['server' => $value])->count();
		if ($currentWorkers >= $maxWorkers) {
			return false;
		}

		return true;
	}
67208
public function count($conditions = false, $count = '1')
    {
        $this->andWhere($conditions);

        $select = $this->sqlParts['select'];
        $this->select('COUNT(' . $count . ')');
        $count = (int)$this->db->fetchColumn($this->getSqlForSelect(true), $this->params);
        $this->sqlParts['select'] = $select;

        return $count;
    }
627323
public static function is_blank( $value ) {
		if ( is_null( $value ) ) {
			return true;
		}

		if ( is_string( $value ) ) {
			return trim( $value ) === '';
		}

		if ( $value instanceof \Countable ) {
			return count( $value ) === 0;
		}

		/* @noinspection TypeUnsafeComparisonInspection */
		if ( 0 === $value || '0' === $value ) {
			return false;
		}

		return empty( $value );
	}