-
Notifications
You must be signed in to change notification settings - Fork 67
Closed
Labels
difficulty: easyfix is easy in difficultyfix is easy in difficulty
Description
Method makeRequest has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Is it possible to move all of this to another method in the class?
$headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$responseBody = substr($response, $headerSize);
$responseHeaders = substr($response, 0, $headerSize);
$responseHeaders = explode("\n", $responseHeaders);
$responseHeaders = array_map('trim', $responseHeaders);
curl_close($curl);
$response = new Response($statusCode, $responseBody, $responseHeaders);
Also, can the retry logic be moved to another method?
if ($statusCode == 429 && $retryOnLimit) {
$headers = $response->headers(true);
$sleepDurations = $headers['X-Ratelimit-Reset'] - time();
sleep($sleepDurations > 0 ? $sleepDurations : 0);
return $this->makeRequest($method, $url, $body, $headers, false);
}
Metadata
Metadata
Assignees
Labels
difficulty: easyfix is easy in difficultyfix is easy in difficulty