Applies a hit to the given regions rate limiting.

@param int $count Default 1
@return bool
343107
public function hit($count = 1)
	{
		$hitsLeft = $this->memcached->get($this->key);
		if ($this->memcached->getResultCode() == Memcached::RES_NOTFOUND)
		{
			// this is the first hit
			$hitsLeft = $this->hits;
			$this->memcached->set($this->key, $this->hits, time() + $this->seconds);
		}

		if ($hitsLeft < $count)
		{
			return false;
		}

		if ($this->memcached->decrement($this->key, $count) === false)
		{
			// it failed to decrement
			return false;
		}

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

        return count($value) == $count;
    }
57971
public function setRetries($count, $delay = 0)
    {
        assert(is_int($count) && $count >= 0);
        assert(is_int($delay) && $delay >= 0);
        $this->_retrycount = $count;
        $this->_retrydelay = $delay;

        return $this;
    }
1110316
public function matches($count, int $maximumCount): bool
    {
        $count = intval($count);
        $result = true;

        if ($count < $this->minimum) {
            $result = false;
        }

        if ($this->maximum >= 0 && $count > $this->maximum) {
            $result = false;
        }

        if ($this->isAlways && $count < $maximumCount) {
            $result = false;
        }

        return $result;
    }
1282502
public static function repeatSecondlyForTotalCount($count, $seconds = 1) {
        if($count < 1) {
            throw new \InvalidArgumentException(sprintf('Total count of firings must be at least one! Given count: "%s"', $count));
        }

        return static::simpleSchedule()
            ->withIntervalInSeconds($seconds)
            ->withRepeatCount($count - 1);
    }
138686
public function limit($sql, $count, $offset = 0)
     {
        $count = intval($count);
        if ($count <= 0) {
            // require_once 'Zend/Db/Adapter/Exception.php';
            throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
        }

        $offset = intval($offset);
        if ($offset < 0) {
            /** @see Zend_Db_Adapter_Exception */
            // require_once 'Zend/Db/Adapter/Exception.php';
            throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
        }

        if ($offset == 0) {
            $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . $count . ' ', $sql);
        } else {
            $orderby = stristr($sql, 'ORDER BY');

            if (!$orderby) {
                $over = 'ORDER BY (SELECT 0)';
            } else {
                $over = preg_replace('/\"[^,]*\".\"([^,]*)\"/i', '"inner_tbl"."$1"', $orderby);
            }

            // Remove ORDER BY clause from $sql
            $sql = preg_replace('/\s+ORDER BY(.*)/', '', $sql);

            // Add ORDER BY clause as an argument for ROW_NUMBER()
            $sql = "SELECT ROW_NUMBER() OVER ($over) AS \"ZEND_DB_ROWNUM\", * FROM ($sql) AS inner_tbl";

            $start = $offset + 1;
            $end = $offset + $count;

            $sql = "WITH outer_tbl AS ($sql) SELECT * FROM outer_tbl WHERE \"ZEND_DB_ROWNUM\" BETWEEN $start AND $end";
        }

        return $sql;
    }
1123919
public static function repeatHourlyForTotalCount($count, $hours = 1) {
        if($count < 1) {
            throw new \InvalidArgumentException(sprintf('Total count of firings must be at least one! Given count: "%s"', $count));
        }

        return static::simpleSchedule()
            ->withIntervalInHours($hours)
            ->withRepeatCount($count - 1);
    }
528597
public function hit(Endpoint $endpoint, $count = 1)
    {
        $region = $endpoint->getRegion();
        $limitsForRegion = $this->limits->getLimitsForRegion($region);
        
        foreach ($limitsForRegion as $time => $limit) {
            // Get the respective time limit for this region
            $item = $this->get($region, $time);
            
            // No results found, create new count for the limit
            if (! $item->isHit()) {
                $item->set($count)->expiresAfter($time);
                $this->store->save($item);
                continue;
            }
            
            // Otherwise there is a count saved for the region,
            // check if the request count can be performed.
            $currentCount = $item->get();
            if ($count + $currentCount > $limit) {
                $message = "Sending {$count} request".($count === 1 ? '' : 's')." is not allowed! ".
                    "Rate limit for '{$region->getName()}' reached. Current count: {$currentCount}. Limits:".
                    array_reduce(array_keys($limitsForRegion), function ($str, $time) use ($limitsForRegion) {
                        return "{$str} {$limitsForRegion[$time]}/{$time}s";
                    }, '');
                throw new RateLimitReachedException($message);
            }
            
            // If it can, increase the current limit
            $item->set($currentCount + $count);
            $this->store->save($item);
        }
        
        return true;
    }
450416
public function spop($key, $count = 1)
    {
        $this->init();
        if ($count == 1 || $count === null) {
            $result = $this->driver->spop($key);
            return $this->convertFalseToNull($result);
        }

        $members = [];
        for ($i = 0; $i < $count; ++$i) {
            $member = $this->driver->spop($key);
            if (!$member) {
                break;
            }
            $members[] = $member;
        }
        return empty($members) ? null : $members;
    }
1140584
public function takeLast(int $count)
    {
        return $this->wrap(function (Iterator $data) use ($count) {
            // From the end of the collection
            $limit = max(0, $count);
            $chunk = [];

            foreach ($data as $key => $datum) {
                $chunk[] = [$key, $datum];
                if (count($chunk) > $limit) {
                    array_shift($chunk);
                }
            }

            foreach ($chunk as $item) {
                [$key, $datum] = $item;
                yield $key => $datum;
            }
        });
    }
463936
public function left ( $count = 0 ) {
        $this->_currentPosition = array(
                                        $this->_currentPosition[0] - $count,
                                        $this->_currentPosition[1],
                                       );
        return $this;
    }
1115219
public function paginate(int $count)
    {
        $this->count = $count;

        $this->treatmentPerPage();
                        
        if ($this->perPage !== null) {
            $this->nbPages = ceil($this->count / $this->perPage);
        } else {
            $this->nbPages = 1;
        }

        if ($this->getP !== null && $this->getP > 0 && $this->getP <= $this->nbPages && preg_match(self::REGEX_INTEGER, $this->getP)) {
            $this->currentPage = $this->getP;
        } else {
            $this->currentPage = 1;
        }

        $this->setLimitAndSetOffset();
    }
3014
public function decrementQuantity(int $count = 1)
    {
        $this->updateQuantity(max(1, $this->quantity - $count));

        return $this;
    }
583863
protected function cacheCountBetween($count, Carbon $from, Carbon $until, $locale, $cacheKey)
    {
        // Cache only if cacheKey is present
        if ($cacheKey && ($until->timestamp < Carbon::now()->timestamp))
        {
            $key = $this->makeBetweenCacheKey($from, $until, $locale, $cacheKey);

            $this->cache->put($key, $count, 525600);
        }
    }
514487
public function chunk( $count, callable $callback )
	{
		$results = $this->forPage( $page = 1, $count )->get();

		while ( count( $results ) > 0 )
		{
			// On each chunk result set, we will pass them to the callback and then let the
			// developer take care of everything within the callback, which allows us to
			// keep the memory low for spinning through large result sets for working.
			if ( call_user_func( $callback, $results ) === false )
			{
				return false;
			}

			$page++;

			$results = $this->forPage( $page, $count )->get();
		}

		return true;
	}
351741
public function getConstrainedKeysByCount($count, $operator = '>=')
	{
		$associativeLocal = $this->associativeLocal;

		return $this->getConstrainedKeys(function($related) use ($count, $associativeLocal, $operator)
		{
			$related->group($associativeLocal)->having('COUNT(*)', $operator, $count);
		});
	}
331311
function SetRetries ( $count, $delay=0 )
    {
        assert ( is_int($count) && $count>=0 );
        assert ( is_int($delay) && $delay>=0 );
        $this->_retrycount = $count;
        $this->_retrydelay = $delay;
    }