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.

Client::accounts()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
ccs 0
cts 8
cp 0
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace WyriHaximus\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 WyriHaximus\Travis\Resource\RepositoryInterface;
11
use WyriHaximus\Travis\Resource\SSHKeyInterface;
12
use WyriHaximus\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));
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 accounts(): array
90
    {
91
        return await(
92
            Promise::fromObservable(
93
                $this->client->accounts()->toArray()
94
            ),
95
            $this->loop
96
        );
97
    }
98
99
    /**
100
     * @return array
101
     */
102
    public function broadcasts(): array
103
    {
104
        return await(
105
            Promise::fromObservable(
106
                $this->client->broadcasts()->toArray()
107
            ),
108
            $this->loop
109
        );
110
    }
111
}
112