src/Stiphle/Throttle/LeakyBucket.php
protected function getNewRatio($key, $limit, $milliseconds)
    {
        $lastRequest = $this->getLastRequest($key) ?: 0;
        $lastRatio   = $this->getLastRatio($key) ?: 0;

        $diff = (microtime(1) - $lastRequest) * 1000;

        $newRatio = $lastRatio - $diff;
        $newRatio = $newRatio < 0 ? 0 : $newRatio;
        $newRatio+= $milliseconds/$limit;

        return $newRatio;
    }
protected function getNewRatio($key, $limit, $milliseconds)
    {
        $lastRequest = $this->getLastRequest($key) ?: 0;
        $lastRatio   = $this->getLastRatio($key) ?: 0;

        $diff = (microtime(1) - $lastRequest) * 1000;

        $newRatio = $lastRatio - $diff;
        $newRatio = $newRatio < 0 ? 0 : $newRatio;
        $newRatio+= $milliseconds/$limit;

        return $newRatio;
    }
protected function getNewRatio ( $ key , $ limit , $ milliseconds ) { $ lastRequest = $ this -> getLastRequest ( $ key ) ? : 0 ; $ lastRatio = $ this -> getLastRatio ( $ key ) ? : 0 ; $ diff = ( microtime ( 1 ) - $ lastRequest ) * 1000 ; $ newRatio = $ lastRatio - $ diff ; $ newRatio = $ newRatio < 0 ? 0 : $ newRatio ; $ newRatio += $ milliseconds / $ limit ; return $ newRatio ; }
Get new ratio

Assuming we're making a request, get the ratio of requests made to
requests allowed

@param string $key  - A unique key for what we're throttling
@param int $limit   - How many are allowed
@param int $milliseconds - In this many milliseconds
@return float
Get new ratio