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.

IsGdShortener::shortenAsync()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
namespace LaraCrafts\UrlShortener\Http;
4
5
use GuzzleHttp\ClientInterface;
6
use GuzzleHttp\Psr7\Request;
7
use Illuminate\Support\Arr;
8
use Psr\Http\Message\ResponseInterface;
9
10
class IsGdShortener extends RemoteShortener
11
{
12
    protected $client;
13
    protected $defaults;
14
15
    /**
16
     * Create a new Is.gd shortener.
17
     *
18
     * @param \GuzzleHttp\ClientInterface $client
19
     * @param \Psr\Http\Message\UriInterface|string $baseUri
20
     * @param bool $statistics
21
     * @return void
22
     */
23 60
    public function __construct(ClientInterface $client, $baseUri, bool $statistics)
24
    {
25 60
        $this->client = $client;
26 60
        $this->defaults = [
27 60
            'allow_redirects' => false,
28 60
            'base_uri' => (string)$baseUri,
29
            'query' => [
30 60
                'format' => 'simple',
31 60
                'logstats' => intval($statistics),
32
            ],
33
        ];
34 60
    }
35
36
    /**
37
     * {@inheritDoc}
38
     */
39 60
    public function shortenAsync($url, array $options = [])
40
    {
41 60
        $options = Arr::add(array_merge_recursive($this->defaults, $options), 'query.url', $url);
42 60
        $request = new Request('GET', '/create.php');
43
44
        return $this->client->sendAsync($request, $options)->then(function (ResponseInterface $response) {
45 50
            return $response->getBody()->getContents();
46 60
        });
47
    }
48
}
49