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.
Passed
Push — master ( c54690...2499fd )
by Choraimy
07:29 queued 27s
created

IsGdShortener::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 3
dl 0
loc 9
ccs 7
cts 7
cp 1
crap 2
rs 10
c 0
b 0
f 0
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 bool $linkPreviews
20
     * @param bool $statistics
21
     * @return void
22
     */
23 120
    public function __construct(ClientInterface $client, bool $linkPreviews, bool $statistics)
24
    {
25 120
        $this->client = $client;
26 120
        $this->defaults = [
27 120
            'allow_redirects' => false,
28 120
            'base_uri' => $linkPreviews ? 'https://v.gd' : 'https://is.gd',
29
            'query' => [
30 120
                'format' => 'simple',
31 120
                'logstats' => intval($statistics),
32
            ],
33
        ];
34 120
    }
35
36
    /**
37
     * {@inheritDoc}
38
     */
39 96
    public function shortenAsync($url, array $options = [])
40
    {
41 96
        $options = Arr::add(array_merge($this->defaults, $options), 'query.url', $url);
42 96
        $request = new Request('GET', '/create.php');
43
44 96
        return $this->client->sendAsync($request, $options)->then(function (ResponseInterface $response) {
45 96
            return $response->getBody()->getContents();
46 96
        });
47
    }
48
}
49