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 ( a9556a...775799 )
by Cees-Jan
10s
created

Client   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 5
dl 0
loc 109
ccs 0
cts 60
cp 0
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A repository() 0 7 1
A user() 0 7 1
A sshKey() 0 7 1
A hooks() 0 9 1
A repositories() 0 9 1
A accounts() 0 9 1
A broadcasts() 0 9 1
1
<?php
2
declare(strict_types=1);
3
4
namespace ApiClients\Client\Travis;
5
6
use ApiClients\Foundation\Factory;
7
use React\EventLoop\Factory as LoopFactory;
8
use React\EventLoop\LoopInterface;
9
use Rx\React\Promise;
10
use ApiClients\Client\Travis\Resource\RepositoryInterface;
11
use ApiClients\Client\Travis\Resource\SSHKeyInterface;
12
use ApiClients\Client\Travis\Resource\UserInterface;
13
use function Clue\React\Block\await;
14
use function React\Promise\resolve;
15
16
class Client
17
{
18
    /**
19
     * @var LoopInterface
20
     */
21
    protected $loop;
22
23
    /**
24
     * @var AsyncClient
25
     */
26
    protected $client;
27
28
    /**
29
     * @param string $token
30
     */
31
    public function __construct(string $token = '')
32
    {
33
        $this->loop = LoopFactory::create();
34
        $this->options = ApiSettings::getOptions($token, 'Sync');
0 ignored issues
show
Bug introduced by
The property options does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
35
        $this->client = new AsyncClient($this->loop, $token, Factory::create($this->loop, $this->options));
0 ignored issues
show
Documentation introduced by
\ApiClients\Foundation\F...->loop, $this->options) is of type object<ApiClients\Foundation\Client>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
36
    }
37
38
    /**
39
     * @param string $repository
40
     * @return RepositoryInterface
41
     */
42
    public function repository(string $repository): RepositoryInterface
43
    {
44
        return await(
45
            $this->client->repository($repository),
46
            $this->loop
47
        );
48
    }
49
50
    /**
51
     * @return UserInterface
52
     */
53
    public function user(): UserInterface
54
    {
55
        return await(
56
            $this->client->user(),
57
            $this->loop
58
        );
59
    }
60
61
    /**
62
     * @param int $id
63
     * @return SSHKeyInterface
64
     */
65
    public function sshKey(int $id): SSHKeyInterface
66
    {
67
        return await(
68
            $this->client->sshKey($id),
69
            $this->loop
70
        );
71
    }
72
73
    /**
74
     * @return array
75
     */
76
    public function hooks(): array
77
    {
78
        return await(
79
            Promise::fromObservable(
80
                $this->client->hooks()->toArray()
81
            ),
82
            $this->loop
83
        );
84
    }
85
86
    /**
87
     * @return array
88
     */
89
    public function repositories(): array
90
    {
91
        return await(
92
            Promise::fromObservable(
93
                $this->client->repositories()->toArray()
94
            ),
95
            $this->loop
96
        );
97
    }
98
99
    /**
100
     * @return array
101
     */
102
    public function accounts(): array
103
    {
104
        return await(
105
            Promise::fromObservable(
106
                $this->client->accounts()->toArray()
107
            ),
108
            $this->loop
109
        );
110
    }
111
112
    /**
113
     * @return array
114
     */
115
    public function broadcasts(): array
116
    {
117
        return await(
118
            Promise::fromObservable(
119
                $this->client->broadcasts()->toArray()
120
            ),
121
            $this->loop
122
        );
123
    }
124
}
125