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\Resource\Repository as BaseRepository; |
23
|
|
|
use React\Promise\PromiseInterface; |
24
|
|
|
use React\Stream\ReadableStreamInterface; |
25
|
|
|
use Rx\Observable; |
26
|
|
|
use Rx\ObservableInterface; |
27
|
|
|
use function ApiClients\Tools\Rx\unwrapObservableFromPromise; |
28
|
|
|
|
29
|
|
|
class Repository extends BaseRepository |
30
|
|
|
{ |
31
|
|
|
public function refresh(): PromiseInterface |
32
|
|
|
{ |
33
|
|
|
return $this->handleCommand( |
34
|
|
|
new RefreshCommand($this) |
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function branches(): ObservableInterface |
39
|
|
|
{ |
40
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
41
|
|
|
new BranchesCommand($this->fullName()) |
42
|
|
|
)); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function commits(): ObservableInterface |
46
|
|
|
{ |
47
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
48
|
|
|
new CommitsCommand($this->fullName()) |
49
|
|
|
)); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function labels(): ObservableInterface |
53
|
|
|
{ |
54
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
55
|
|
|
new LabelsCommand($this->fullName()) |
56
|
|
|
)); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function addLabel(string $name, string $colour): PromiseInterface |
60
|
|
|
{ |
61
|
|
|
return $this->handleCommand( |
62
|
|
|
new AddLabelCommand($this->fullName(), $name, $colour) |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function contents(string $path = '/'): Observable |
67
|
|
|
{ |
68
|
|
|
return unwrapObservableFromPromise( |
69
|
|
|
$this->handleCommand( |
70
|
|
|
new ContentsCommand($this->fullName(), $path) |
71
|
|
|
) |
72
|
|
|
); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function communityHealth(): PromiseInterface |
76
|
|
|
{ |
77
|
|
|
return $this->handleCommand( |
78
|
|
|
new CommunityHealthCommand($this->fullName()) |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function tags(): ObservableInterface |
83
|
|
|
{ |
84
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
85
|
|
|
new TagsCommand($this->fullName()) |
86
|
|
|
)); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function releases(): ObservableInterface |
90
|
|
|
{ |
91
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
92
|
|
|
new ReleasesCommand($this->fullName()) |
93
|
|
|
)); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function languages(): PromiseInterface |
97
|
|
|
{ |
98
|
|
|
return $this->handleCommand( |
99
|
|
|
new LanguagesCommand($this->fullName()) |
100
|
|
|
); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function addFile( |
104
|
|
|
string $filename, |
105
|
|
|
ReadableStreamInterface $stream, |
106
|
|
|
string $commitMessage = '', |
107
|
|
|
string $branch = '' |
108
|
|
|
): PromiseInterface { |
109
|
|
|
if ($commitMessage === '') { |
110
|
|
|
$commitMessage = 'Update ' . $this->name; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
return $this->handleCommand(new FileUploadCommand( |
114
|
|
|
$this->full_name, |
115
|
|
|
$commitMessage, |
116
|
|
|
'/repos/' . $this->full_name . '/contents/' . $filename, |
117
|
|
|
'', |
118
|
|
|
$branch, |
119
|
|
|
$stream |
120
|
|
|
)); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function subscribe(bool $subscribed = true, bool $ignored = false): PromiseInterface |
124
|
|
|
{ |
125
|
|
|
return $this->handleCommand( |
126
|
|
|
new SubscribeCommand($this->fullName(), $subscribed, $ignored) |
127
|
|
|
); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function unSubscribe(): PromiseInterface |
131
|
|
|
{ |
132
|
|
|
return $this->handleCommand( |
133
|
|
|
new UnSubscribeCommand($this->fullName()) |
134
|
|
|
); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function replaceTopics(string ...$topics): PromiseInterface |
138
|
|
|
{ |
139
|
|
|
return $this->handleCommand( |
140
|
|
|
new ReplaceTopicsCommand($this->fullName(), ...$topics) |
141
|
|
|
); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function travisRepository(): PromiseInterface |
145
|
|
|
{ |
146
|
|
|
return $this->handleCommand(new TravisCommand($this->fullName())); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
public function appVeyorRepository(): PromiseInterface |
150
|
|
|
{ |
151
|
|
|
return $this->handleCommand(new AppVeyorCommand($this->fullName())); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
public function scrutinizerRepository(): PromiseInterface |
155
|
|
|
{ |
156
|
|
|
return $this->handleCommand(new ScrutinizerCommand(...explode('/', $this->fullName()))); |
|
|
|
|
157
|
|
|
} |
158
|
|
|
} |
159
|
|
|
|
This check looks for function calls that miss required arguments.