/** * Make the actual request. * * @param bool $static * @param string $uri * @param array $params * @return \LeagueWrap\Response * @throws LimitReachedException */ protected function clientRequest($static, $uri, $params) { // check if we have hit the limit if (!$static && !$this->collection->hitLimits($this->region->getRegion())) { throw new LimitReachedException('You have hit the request limit in your collection.'); } $response = $this->client->request($uri, $params); ++$this->requests; // check if it's a valid response object if ($response instanceof Response) { $this->checkResponseErrors($response); } return $response; }
public function testRemainingHitsMultipleRegions() { $limit1 = new Limit(); $limit1->setRate(25, 10, 'eu'); $limit2 = new Limit(); $limit2->setRate(20, 5, 'na'); $collection = new Collection(); $collection->addLimit($limit1); $collection->addLimit($limit2); $collection->hitLimits('eu', 10); $this->assertEquals(15, $collection->remainingHits()); }