public function testTimeRunOut() { $limit = new FileLimit(); $limit->setRate(8, 0, 'euna'); $limit->hit(8); $this->assertEquals(8, $limit->remaining()); }
/** * Sets a limit to be added to the collection. * * @param int $hits * @param int $seconds * @param string $region * @param Limit $limit * @chainable */ public function limit($hits, $seconds, $region = 'all', LimitInterface $limit = null) { if (is_null($limit)) { // use the built in limit interface $limit = new Limit(); } if (!$limit->isValid()) { // fall back to the file base limit handling $limit = new FileLimit(); if (!$limit->isValid()) { throw new NoValidLimitInterfaceException("We could not load a valid limit interface."); } } if ($region == 'all') { foreach (['br', 'eune', 'euw', 'kr', 'lan', 'las', 'na', 'oce', 'ru', 'tr'] as $region) { $newLimit = $limit->newInstance(); $newLimit->setRate($hits, $seconds, $region); $this->collection->addLimit($newLimit); } } else { // lower case the region $region = strtolower($region); $limit->setRate($hits, $seconds, $region); $this->collection->addLimit($limit); } return $this; }