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