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   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 36
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A shortenAsync() 0 7 1
A __construct() 0 9 2
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