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
Pull Request — master (#33)
by Cees-Jan
13:22 queued 11:17
created

AsyncClient::accounts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 10
loc 10
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace WyriHaximus\Travis;
5
6
use React\EventLoop\LoopInterface;
7
use React\Promise\PromiseInterface;
8
use Rx\Observable;
9
use Rx\ObservableInterface;
10
use Rx\React\Promise;
11
use WyriHaximus\ApiClient\Transport\Client as Transport;
12
use WyriHaximus\ApiClient\Transport\Factory;
13
use function React\Promise\resolve;
14
15
class AsyncClient
16
{
17
    protected $transport;
18
19
    public function __construct(LoopInterface $loop, string $token = '', Transport $transport = null)
20
    {
21 View Code Duplication
        if (!($transport instanceof Transport)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
            $options = [
23
                'resource_namespace' => 'Async',
24
            ] + ApiSettings::TRANSPORT_OPTIONS;
25
26
            if ($token !== '') {
27
                $options['headers']['Authorization'] = 'token ' . $token;
28
            }
29
30
            $transport = Factory::create($loop, $options);
31
        }
32
        $this->transport = $transport;
33
    }
34
35
    public function repository(string $repository): PromiseInterface
36
    {
37
        return $this->transport->request('repos/' . $repository)->then(function ($json) {
38
            return resolve($this->transport->getHydrator()->hydrate('Repository', $json['repo']));
39
        });
40
    }
41
42 View Code Duplication
    public function accounts(): ObservableInterface
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        return Promise::toObservable(
45
            $this->transport->request('accounts')
46
        )->flatMap(function ($response) {
47
            return Observable::fromArray($response['accounts']);
48
        })->map(function ($account) {
49
            return $this->transport->getHydrator()->hydrate('Account', $account);
50
        });
51
    }
52
53 View Code Duplication
    public function broadcasts(): ObservableInterface
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
    {
55
        return Promise::toObservable(
56
            $this->transport->request('broadcasts')
57
        )->flatMap(function ($response) {
58
            return Observable::fromArray($response['broadcasts']);
59
        })->map(function ($broadcast) {
60
            return $this->getTransport()->getHydrator()->hydrate('Broadcast', $broadcast);
0 ignored issues
show
Bug introduced by
The method getTransport() does not seem to exist on object<WyriHaximus\Travis\AsyncClient>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
61
        });
62
    }
63
}
64