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:12
created

Repository::addLabel()   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\BranchesCommand;
8
use ApiClients\Client\Github\CommandBus\Command\Repository\CommitsCommand;
9
use ApiClients\Client\Github\CommandBus\Command\Repository\CommunityHealthCommand;
10
use ApiClients\Client\Github\CommandBus\Command\Repository\Contents\FileUploadCommand;
11
use ApiClients\Client\Github\CommandBus\Command\Repository\ContentsCommand;
12
use ApiClients\Client\Github\CommandBus\Command\Repository\LabelsCommand;
13
use ApiClients\Client\Github\CommandBus\Command\Repository\LanguagesCommand;
14
use ApiClients\Client\Github\CommandBus\Command\Repository\ReleasesCommand;
15
use ApiClients\Client\Github\CommandBus\Command\Repository\SubscribeCommand;
16
use ApiClients\Client\Github\CommandBus\Command\Repository\TagsCommand;
17
use ApiClients\Client\Github\CommandBus\Command\Repository\UnSubscribeCommand;
18
use ApiClients\Client\Github\CommandBus\Command\Repository\WebHooksCommand;
19
use ApiClients\Client\Github\Resource\Repository as BaseRepository;
20
use React\Promise\PromiseInterface;
21
use React\Stream\ReadableStreamInterface;
22
use Rx\Observable;
23
use Rx\ObservableInterface;
24
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
25
26
class Repository extends BaseRepository
27
{
28
    public function refresh(): PromiseInterface
29
    {
30
        return $this->handleCommand(
31
            new RefreshCommand($this)
32
        );
33
    }
34
35
    public function branches(): ObservableInterface
36
    {
37
        return unwrapObservableFromPromise($this->handleCommand(
38
            new BranchesCommand($this->fullName())
39
        ));
40
    }
41
42
    public function commits(): ObservableInterface
43
    {
44
        return unwrapObservableFromPromise($this->handleCommand(
45
            new CommitsCommand($this->fullName())
46
        ));
47
    }
48
49
    public function labels(): ObservableInterface
50
    {
51
        return unwrapObservableFromPromise($this->handleCommand(
52
            new LabelsCommand($this->fullName())
53
        ));
54
    }
55
56
    public function addLabel(string $name, string $colour): PromiseInterface
57
    {
58
        return $this->handleCommand(
59
            new AddLabelCommand($this->fullName(), $name, $colour)
60
        );
61
    }
62
63
    public function contents(string $path = '/'): Observable
64
    {
65
        return unwrapObservableFromPromise(
66
            $this->handleCommand(
67
                new ContentsCommand($this->fullName(), $path)
68
            )
69
        );
70
    }
71
72
    public function communityHealth(): PromiseInterface
73
    {
74
        return $this->handleCommand(
75
            new CommunityHealthCommand($this->fullName())
76
        );
77
    }
78
79
    public function tags(): ObservableInterface
80
    {
81
        return unwrapObservableFromPromise($this->handleCommand(
82
            new TagsCommand($this->fullName())
83
        ));
84
    }
85
86
    public function releases(): ObservableInterface
87
    {
88
        return unwrapObservableFromPromise($this->handleCommand(
89
            new ReleasesCommand($this->fullName())
90
        ));
91
    }
92
93
    public function languages(): PromiseInterface
94
    {
95
        return $this->handleCommand(
96
            new LanguagesCommand($this->fullName())
97
        );
98
    }
99
100
    public function webHooks(): ObservableInterface
101
    {
102
        return unwrapObservableFromPromise($this->handleCommand(
103
            new WebHooksCommand($this->fullName())
104
        ));
105
    }
106
107
    public function addFile(
108
        string $filename,
109
        ReadableStreamInterface $stream,
110
        string $commitMessage = '',
111
        string $branch = ''
112
    ): PromiseInterface {
113
        if ($commitMessage === '') {
114
            $commitMessage = 'Update ' . $this->name;
115
        }
116
117
        return $this->handleCommand(new FileUploadCommand(
118
            $this->full_name,
119
            $commitMessage,
120
            '/repos/' . $this->full_name . '/contents/' . $filename,
121
            '',
122
            $branch,
123
            $stream
124
        ));
125
    }
126
127
    public function subscribe(bool $subscribed = true, bool $ignored = false): PromiseInterface
128
    {
129
        return $this->handleCommand(
130
            new SubscribeCommand($this->fullName(), $subscribed, $ignored)
131
        );
132
    }
133
134
    public function unSubscribe(): PromiseInterface
135
    {
136
        return $this->handleCommand(
137
            new UnSubscribeCommand($this->fullName())
138
        );
139
    }
140
}
141