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 ( c77907...638f4c )
by Choraimy
06:10
created

OuoIoShortener::shortenAsync()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
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 OuoIoShortener extends RemoteShortener
11
{
12
    protected $client;
13
    protected $defaults;
14
    protected $token;
15
16
    /**
17
     * Create a new Ouo.io shortener.
18
     *
19
     * @param \GuzzleHttp\ClientInterface $client
20
     * @param string $token
21
     * @return void
22
     */
23 42
    public function __construct(ClientInterface $client, string $token)
24
    {
25 42
        $this->client = $client;
26 42
        $this->defaults = [
27
            'allow_redirects' => false,
28
            'base_uri' => 'https://ouo.io',
29
        ];
30 42
        $this->token = $token;
31 42
    }
32
33
    /**
34
     * {@inheritDoc}
35
     */
36 18
    public function shortenAsync($url, array $options = [])
37
    {
38 18
        $options = array_merge(Arr::add($this->defaults, 'query.s', $url), $options);
39 18
        $request = new Request('GET', "/api/$this->token");
40
41 18
        return $this->client->sendAsync($request, $options)->then(function (ResponseInterface $response) {
42 18
            return $response->getBody()->getContents();
43 18
        });
44
    }
45
}
46