function DiagnoseCommand::getGithubRateLimit
Parameters
string $token:
Return value
mixed|string
Throws
1 call to DiagnoseCommand::getGithubRateLimit()
- DiagnoseCommand::execute in vendor/
composer/ composer/ src/ Composer/ Command/ DiagnoseCommand.php - Executes the current command.
File
-
vendor/
composer/ composer/ src/ Composer/ Command/ DiagnoseCommand.php, line 474
Class
- DiagnoseCommand
- @author Jordi Boggiano <j.boggiano@seld.be>
Namespace
Composer\CommandCode
private function getGithubRateLimit(string $domain, ?string $token = null) {
$result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
if ($result !== true) {
return $result;
}
if ($token) {
$this->getIO()
->setAuthentication($domain, $token, 'x-oauth-basic');
}
$url = $domain === 'github.com' ? 'https://api.' . $domain . '/rate_limit' : 'https://' . $domain . '/api/rate_limit';
$data = $this->httpDownloader
->get($url, [
'retry-auth-failure' => false,
])
->decodeJson();
return $data['resources']['core'];
}