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 (#20)
by Cees-Jan
07:58
created

Repository::subscribe()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Github\Resource\Async;
4
5
use ApiClients\Client\Github\CommandBus\Command\RefreshCommand;
6
use ApiClients\Client\Github\CommandBus\Command\Repository\AddLabelCommand;
7
use ApiClients\Client\Github\CommandBus\Command\Repository\AppVeyorCommand;
8
use ApiClients\Client\Github\CommandBus\Command\Repository\BranchesCommand;
9
use ApiClients\Client\Github\CommandBus\Command\Repository\CommitsCommand;
10
use ApiClients\Client\Github\CommandBus\Command\Repository\CommunityHealthCommand;
11
use ApiClients\Client\Github\CommandBus\Command\Repository\Contents\FileUploadCommand;
12
use ApiClients\Client\Github\CommandBus\Command\Repository\ContentsCommand;
13
use ApiClients\Client\Github\CommandBus\Command\Repository\LabelsCommand;
14
use ApiClients\Client\Github\CommandBus\Command\Repository\LanguagesCommand;
15
use ApiClients\Client\Github\CommandBus\Command\Repository\ReleasesCommand;
16
use ApiClients\Client\Github\CommandBus\Command\Repository\ReplaceTopicsCommand;
17
use ApiClients\Client\Github\CommandBus\Command\Repository\ScrutinizerCommand;
18
use ApiClients\Client\Github\CommandBus\Command\Repository\SubscribeCommand;
19
use ApiClients\Client\Github\CommandBus\Command\Repository\TagsCommand;
20
use ApiClients\Client\Github\CommandBus\Command\Repository\TravisCommand;
21
use ApiClients\Client\Github\CommandBus\Command\Repository\UnSubscribeCommand;
22
use ApiClients\Client\Github\CommandBus\Command\WebHooksCommand;
23
use ApiClients\Client\Github\Resource\Repository as BaseRepository;
24
use React\Promise\PromiseInterface;
25
use React\Stream\ReadableStreamInterface;
26
use Rx\Observable;
27
use Rx\ObservableInterface;
28
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
29
30
class Repository extends BaseRepository
31
{
32
    public function refresh(): PromiseInterface
33
    {
34
        return $this->handleCommand(
35
            new RefreshCommand($this)
36
        );
37
    }
38
39
    public function branches(): ObservableInterface
40
    {
41
        return unwrapObservableFromPromise($this->handleCommand(
42
            new BranchesCommand($this->fullName())
43
        ));
44
    }
45
46
    public function commits(): ObservableInterface
47
    {
48
        return unwrapObservableFromPromise($this->handleCommand(
49
            new CommitsCommand($this->fullName())
50
        ));
51
    }
52
53
    public function labels(): ObservableInterface
54
    {
55
        return unwrapObservableFromPromise($this->handleCommand(
56
            new LabelsCommand($this->fullName())
57
        ));
58
    }
59
60
    public function addLabel(string $name, string $colour): PromiseInterface
61
    {
62
        return $this->handleCommand(
63
            new AddLabelCommand($this->fullName(), $name, $colour)
64
        );
65
    }
66
67
    public function contents(string $path = '/'): Observable
68
    {
69
        return unwrapObservableFromPromise(
70
            $this->handleCommand(
71
                new ContentsCommand($this->fullName(), $path)
72
            )
73
        );
74
    }
75
76
    public function communityHealth(): PromiseInterface
77
    {
78
        return $this->handleCommand(
79
            new CommunityHealthCommand($this->fullName())
80
        );
81
    }
82
83
    public function tags(): ObservableInterface
84
    {
85
        return unwrapObservableFromPromise($this->handleCommand(
86
            new TagsCommand($this->fullName())
87
        ));
88
    }
89
90
    public function releases(): ObservableInterface
91
    {
92
        return unwrapObservableFromPromise($this->handleCommand(
93
            new ReleasesCommand($this->fullName())
94
        ));
95
    }
96
97
    public function languages(): PromiseInterface
98
    {
99
        return $this->handleCommand(
100
            new LanguagesCommand($this->fullName())
101
        );
102
    }
103
104
    public function webHooks(): ObservableInterface
105
    {
106
        return unwrapObservableFromPromise($this->handleCommand(
107
            new WebHooksCommand($this->fullName(), 'repos')
108
        ));
109
    }
110
111
    public function addFile(
112
        string $filename,
113
        ReadableStreamInterface $stream,
114
        string $commitMessage = '',
115
        string $branch = ''
116
    ): PromiseInterface {
117
        if ($commitMessage === '') {
118
            $commitMessage = 'Update ' . $this->name;
119
        }
120
121
        return $this->handleCommand(new FileUploadCommand(
122
            $this->full_name,
123
            $commitMessage,
124
            '/repos/' . $this->full_name . '/contents/' . $filename,
125
            '',
126
            $branch,
127
            $stream
128
        ));
129
    }
130
131
    public function subscribe(bool $subscribed = true, bool $ignored = false): PromiseInterface
132
    {
133
        return $this->handleCommand(
134
            new SubscribeCommand($this->fullName(), $subscribed, $ignored)
135
        );
136
    }
137
138
    public function unSubscribe(): PromiseInterface
139
    {
140
        return $this->handleCommand(
141
            new UnSubscribeCommand($this->fullName())
142
        );
143
    }
144
145
    public function replaceTopics(string ...$topics): PromiseInterface
146
    {
147
        return $this->handleCommand(
148
            new ReplaceTopicsCommand($this->fullName(), ...$topics)
149
        );
150
    }
151
152
    public function travisRepository(): PromiseInterface
153
    {
154
        return $this->handleCommand(new TravisCommand($this->fullName()));
155
    }
156
157
    public function appVeyorRepository(): PromiseInterface
158
    {
159
        return $this->handleCommand(new AppVeyorCommand($this->fullName()));
160
    }
161
162
    public function scrutinizerRepository(): PromiseInterface
163
    {
164
        return $this->handleCommand(new ScrutinizerCommand(...explode('/', $this->fullName())));
0 ignored issues
show
Bug introduced by
The call to ScrutinizerCommand::__construct() misses a required argument $name.

This check looks for function calls that miss required arguments.

Loading history...
Documentation introduced by
explode('/', $this->fullName()) is of type array, but the function expects a string.

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...
165
    }
166
}
167