GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#97)
by Pierre
04:47 queued 02:18
created

GuzzleClientFactory::make()   B

Complexity

Conditions 5
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 7
nc 1
nop 2
1
<?php
2
3
namespace Spatie\UptimeMonitor;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\Middleware;
7
use GuzzleHttp\HandlerStack;
8
use Psr\Http\Message\RequestInterface;
9
use Psr\Http\Message\ResponseInterface;
10
use GuzzleHttp\Exception\ConnectException;
11
use GuzzleHttp\Exception\TransferException;
12
13
/**
14
 * This is the guzzle factory class.
15
 *
16
 * @author Graham Campbell <[email protected]>
17
 */
18
final class GuzzleClientFactory
19
{
20
    public static function make(array $options = [], int $backoff = 1000): Client
21
    {
22
        $stack = HandlerStack::create();
23
        $stack->push(Middleware::retry(function ($retries, RequestInterface $request, ResponseInterface $response = null, TransferException $exception = null) {
24
            return $retries < 3 && ($exception instanceof ConnectException || ($response && ($response->getStatusCode() >= 500 || $response->getStatusCode() === 429)));
25
        }, function ($retries) use ($backoff) {
26
            return (int) 2 ** $retries * $backoff;
27
        }));
28
29
        return new Client(array_merge(['handler' => $stack, 'connect_timeout' => 10, 'timeout' => 15], $options));
30
    }
31
}
32