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 (#62)
by Cees-Jan
09:39
created

Repository::specificCommit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 5
cp 0
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
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\AddWebHookCommand;
8
use ApiClients\Client\Github\CommandBus\Command\Repository\AppVeyorCommand;
9
use ApiClients\Client\Github\CommandBus\Command\Repository\BlobCommand;
10
use ApiClients\Client\Github\CommandBus\Command\Repository\BranchesCommand;
11
use ApiClients\Client\Github\CommandBus\Command\Repository\CommitCommand;
12
use ApiClients\Client\Github\CommandBus\Command\Repository\CommitsCommand;
13
use ApiClients\Client\Github\CommandBus\Command\Repository\CommunityHealthCommand;
14
use ApiClients\Client\Github\CommandBus\Command\Repository\Contents\FileUploadCommand;
15
use ApiClients\Client\Github\CommandBus\Command\Repository\ContentsCommand;
16
use ApiClients\Client\Github\CommandBus\Command\Repository\DetailedCommitCommand;
17
use ApiClients\Client\Github\CommandBus\Command\Repository\LabelsCommand;
18
use ApiClients\Client\Github\CommandBus\Command\Repository\LanguagesCommand;
19
use ApiClients\Client\Github\CommandBus\Command\Repository\RefCommand;
20
use ApiClients\Client\Github\CommandBus\Command\Repository\RefsCommand;
21
use ApiClients\Client\Github\CommandBus\Command\Repository\ReleasesCommand;
22
use ApiClients\Client\Github\CommandBus\Command\Repository\ReplaceTopicsCommand;
23
use ApiClients\Client\Github\CommandBus\Command\Repository\ScrutinizerCommand;
24
use ApiClients\Client\Github\CommandBus\Command\Repository\SubscribeCommand;
25
use ApiClients\Client\Github\CommandBus\Command\Repository\TagsCommand;
26
use ApiClients\Client\Github\CommandBus\Command\Repository\TravisCommand;
27
use ApiClients\Client\Github\CommandBus\Command\Repository\TreeCommand;
28
use ApiClients\Client\Github\CommandBus\Command\Repository\UnSubscribeCommand;
29
use ApiClients\Client\Github\CommandBus\Command\Repository\UpdateSettingsCommand;
30
use ApiClients\Client\Github\CommandBus\Command\WebHooksCommand;
31
use ApiClients\Client\Github\Resource\Git\CommitInterface;
32
use ApiClients\Client\Github\Resource\Git\RefInterface;
33
use ApiClients\Client\Github\Resource\Git\TreeInterface;
34
use ApiClients\Client\Github\Resource\Repository as BaseRepository;
35
use ApiClients\Client\Github\VO\NamedBlob;
36
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
37
use React\Promise\PromiseInterface;
38
use React\Stream\ReadableStreamInterface;
39
use Rx\Observable;
40
use Rx\ObservableInterface;
41
42
class Repository extends BaseRepository
43
{
44
    public function refresh(): PromiseInterface
45
    {
46
        return $this->handleCommand(
47
            new RefreshCommand($this)
48
        );
49
    }
50
51
    public function branches(): ObservableInterface
52
    {
53
        return unwrapObservableFromPromise($this->handleCommand(
54
            new BranchesCommand($this->fullName())
55
        ));
56
    }
57
58
    public function commits(): ObservableInterface
59
    {
60
        return unwrapObservableFromPromise($this->handleCommand(
61
            new CommitsCommand($this->fullName())
62
        ));
63
    }
64
65
    public function specificCommit(string $sha): PromiseInterface
66
    {
67
        return $this->handleCommand(
68
            new DetailedCommitCommand(
69
                $this->fullName(),
70
                $sha
71
            )
72
        );
73
    }
74
75
    public function labels(): ObservableInterface
76
    {
77
        return unwrapObservableFromPromise($this->handleCommand(
78
            new LabelsCommand($this->fullName())
79
        ));
80
    }
81
82
    public function addLabel(string $name, string $colour): PromiseInterface
83
    {
84
        return $this->handleCommand(
85
            new AddLabelCommand($this->fullName(), $name, $colour)
86
        );
87
    }
88
89
    public function contents(string $path = '/'): Observable
90
    {
91
        return unwrapObservableFromPromise(
92
            $this->handleCommand(
93
                new ContentsCommand($this->fullName(), $path)
94
            )
95
        );
96
    }
97
98
    public function communityHealth(): PromiseInterface
99
    {
100
        return $this->handleCommand(
101
            new CommunityHealthCommand($this->fullName())
102
        );
103
    }
104
105
    public function tags(): ObservableInterface
106
    {
107
        return unwrapObservableFromPromise($this->handleCommand(
108
            new TagsCommand($this->fullName())
109
        ));
110
    }
111
112
    public function releases(): ObservableInterface
113
    {
114
        return unwrapObservableFromPromise($this->handleCommand(
115
            new ReleasesCommand($this->fullName())
116
        ));
117
    }
118
119
    public function languages(): PromiseInterface
120
    {
121
        return $this->handleCommand(
122
            new LanguagesCommand($this->fullName())
123
        );
124
    }
125
126
    public function webHooks(): ObservableInterface
127
    {
128
        return unwrapObservableFromPromise($this->handleCommand(
129
            new WebHooksCommand($this->fullName(), 'repos')
130
        ));
131
    }
132
133
    public function addWebHook(
134
        string $name,
135
        array $config,
136
        array $events,
137
        bool $active
138
    ): PromiseInterface {
139
        return $this->handleCommand(
140
            new AddWebHookCommand(
141
                $this->fullName(),
142
                $name,
143
                $config,
144
                $events,
145
                $active
146
            )
147
        );
148
    }
149
150
    public function addFile(
151
        string $filename,
152
        ReadableStreamInterface $stream,
153
        string $commitMessage = '',
154
        string $branch = ''
155
    ): PromiseInterface {
156
        if ($commitMessage === '') {
157
            $commitMessage = 'Update ' . $this->name;
158
        }
159
160
        return $this->handleCommand(new FileUploadCommand(
161
            $this->full_name,
162
            $commitMessage,
163
            '/repos/' . $this->full_name . '/contents/' . $filename,
164
            '',
165
            $branch,
166
            $stream
167
        ));
168
    }
169
170
    public function subscribe(bool $subscribed = true, bool $ignored = false): PromiseInterface
171
    {
172
        return $this->handleCommand(
173
            new SubscribeCommand($this->fullName(), $subscribed, $ignored)
174
        );
175
    }
176
177
    public function unSubscribe(): PromiseInterface
178
    {
179
        return $this->handleCommand(
180
            new UnSubscribeCommand($this->fullName())
181
        );
182
    }
183
184
    public function replaceTopics(string ...$topics): PromiseInterface
185
    {
186
        return $this->handleCommand(
187
            new ReplaceTopicsCommand($this->fullName(), ...$topics)
188
        );
189
    }
190
191
    public function travisRepository(): PromiseInterface
192
    {
193
        return $this->handleCommand(new TravisCommand($this->fullName()));
194
    }
195
196
    public function appVeyorRepository(): PromiseInterface
197
    {
198
        return $this->handleCommand(new AppVeyorCommand($this->fullName()));
199
    }
200
201
    public function scrutinizerRepository(): PromiseInterface
202
    {
203
        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...
204
    }
205
206
    public function updateSettings(array $settings): PromiseInterface
207
    {
208
        if (!isset($settings['name'])) {
209
            $settings['name'] = $this->name();
210
        }
211
212
        return $this->handleCommand(new UpdateSettingsCommand($this->fullName(), $settings));
213
    }
214
215
    public function blob(ReadableStreamInterface $contents): PromiseInterface
216
    {
217
        return $this->handleCommand(new BlobCommand($this->fullName(), $contents));
218
    }
219
220
    public function tree(?string $baseTree, NamedBlob ...$blobs): PromiseInterface
221
    {
222
        return $this->handleCommand(new TreeCommand($this->fullName(), $baseTree, ...$blobs));
223
    }
224
225
    public function commit(string $message, TreeInterface $tree, ?string ...$baseCommits): PromiseInterface
226
    {
227
        return $this->handleCommand(new CommitCommand($this->fullName(), $message, $tree->sha(), ...$baseCommits));
228
    }
229
230
    public function refs(?string $namespace = null): ObservableInterface
231
    {
232
        return unwrapObservableFromPromise($this->handleCommand(
233
            new RefsCommand($this->fullName(), $namespace)
234
        ));
235
    }
236
237
    public function ref(RefInterface $ref, CommitInterface $tree): PromiseInterface
238
    {
239
        return $this->handleCommand(new RefCommand($this->fullName(), $ref->ref(), $tree->sha()));
240
    }
241
}
242