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
Push — master ( 71a4f9...212da1 )
by Cees-Jan
06:21
created

Client::request()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace WyriHaximus\Travis;
4
5
use GuzzleHttp\Psr7\Request;
6
use Psr\Http\Message\ResponseInterface;
7
use React\Promise\Deferred;
8
9
class Client
10
{
11
    const VERSION = '0.0.1-alpha1';
12
    const USER_AGENT = 'wyrihaximus/travis-client/' . self::VERSION;
13
    const API_VERSION = 'application/vnd.travis-ci.2+json';
14
    const API_HOST_OPEN_SOURCE = 'api.travis-ci.org';
15
    const API_HOST_PRO = 'api.travis-ci.com';
16
    const API_HOST = self::API_HOST_OPEN_SOURCE;
17
    const API_SCHEMA = 'https';
18
19
    /**
20
     * @var callable
21
     */
22
    protected $handler;
23
24
    public function __construct(callable $handler = null)
25
    {
26
        if ($handler === null) {
27
            $handler = \Aws\default_http_handler();
28
        }
29
30
        $this->handler = $handler;
31
    }
32
33
    public function request(EndpointInterface $endpoint)
34
    {
35
        $handler = $this->handler;
36
        return $endpoint->fromResponse($handler($endpoint->getRequest())->wait());
37
    }
38
39
    public function requestAsync(EndpointInterface $endpoint)
40
    {
41
        $deferred = new Deferred();
42
        $handler = $this->handler;
43
        $handler($endpoint->getRequest())->then(function (ResponseInterface $response) use ($deferred, $endpoint) {
44
            var_export($endpoint->fromResponse($response));
45
            $deferred->resolve($endpoint->fromResponse($response));
46
        });
47
        return $deferred->promise();
48
    }
49
50
    public function createRequert(string $method, string $path)
51
    {
52
        $url = self::API_SCHEMA . '://' . self::API_HOST . '/' . $path;
53
        return new Request($method, $url, [
54
            'User-Agent' => self::USER_AGENT,
55
            'Accept' => self::API_VERSION,
56
        ]);
57
    }
58
}
59