Update composer dependencies

This commit is contained in:
Chris
2019-06-11 12:29:32 +01:00
parent 7d6df3843b
commit 1f608b1c21
1835 changed files with 74500 additions and 27482 deletions

View File

@@ -2,6 +2,8 @@
namespace Github\Api;
use Github\Api\RateLimit\RateLimitResource;
/**
* Get rate limits.
*
@@ -12,36 +14,93 @@ namespace Github\Api;
class RateLimit extends AbstractApi
{
/**
* Get rate limits.
* @var RateLimitResource[]
*/
protected $resources = [];
/**
* Get rate limits data in an array.
*
* @deprecated since 2.11.0 Use `->getResources()` instead
*
* @return array
*/
public function getRateLimits()
{
return $this->get('/rate_limit');
return $this->fetchLimits();
}
/**
* Gets the rate limit resource objects.
*
* @return RateLimitResource[]
*/
public function getResources()
{
$this->fetchLimits();
return $this->resources;
}
/**
* Returns a rate limit resource object by the given name.
*
* @param string $name
*
* @return RateLimitResource|false
*/
public function getResource($name)
{
// Fetch once per instance
if (empty($this->resources)) {
$this->fetchLimits();
}
if (!isset($this->resources[$name])) {
return false;
}
return $this->resources[$name];
}
/**
* Returns the data directly from the GitHub API endpoint.
*
* @return array
*/
protected function fetchLimits()
{
$result = $this->get('/rate_limit') ?: [];
// Assemble Limit instances
foreach ($result['resources'] as $resourceName => $resource) {
$this->resources[$resourceName] = new RateLimitResource($resourceName, $resource);
}
return $result;
}
/**
* Get core rate limit.
*
* @deprecated since 2.11.0 Use `->getResource('core')->getLimit()` instead
*
* @return int
*/
public function getCoreLimit()
{
$response = $this->getRateLimits();
return $response['resources']['core']['limit'];
return $this->getResource('core')->getLimit();
}
/**
* Get search rate limit.
*
* @deprecated since 2.11.0 Use `->getResource('core')->getLimit()` instead
*
* @return int
*/
public function getSearchLimit()
{
$response = $this->getRateLimits();
return $response['resources']['search']['limit'];
return $this->getResource('search')->getLimit();
}
}