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\ContentsCommand; |
11
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\LabelsCommand; |
12
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\ReleasesCommand; |
13
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\TagsCommand; |
14
|
|
|
use ApiClients\Client\Github\Resource\Repository as BaseRepository; |
15
|
|
|
use React\Promise\PromiseInterface; |
16
|
|
|
use Rx\Observable; |
17
|
|
|
use Rx\ObservableInterface; |
18
|
|
|
use function ApiClients\Tools\Rx\unwrapObservableFromPromise; |
19
|
|
|
|
20
|
|
|
class Repository extends BaseRepository |
21
|
|
|
{ |
22
|
|
|
public function refresh(): PromiseInterface |
23
|
|
|
{ |
24
|
|
|
return $this->handleCommand( |
25
|
|
|
new RefreshCommand($this) |
26
|
|
|
); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function branches(): ObservableInterface |
30
|
|
|
{ |
31
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
32
|
|
|
new BranchesCommand($this->fullName()) |
33
|
|
|
)); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function commits(): ObservableInterface |
37
|
|
|
{ |
38
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
39
|
|
|
new CommitsCommand($this->fullName()) |
40
|
|
|
)); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function labels(): ObservableInterface |
44
|
|
|
{ |
45
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
46
|
|
|
new LabelsCommand($this->fullName()) |
47
|
|
|
)); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function addLabel(string $name, string $colour): PromiseInterface |
51
|
|
|
{ |
52
|
|
|
return $this->handleCommand( |
53
|
|
|
new AddLabelCommand($this->fullName(), $name, $colour) |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function contents(string $path = '/'): Observable |
58
|
|
|
{ |
59
|
|
|
return unwrapObservableFromPromise( |
60
|
|
|
$this->handleCommand( |
61
|
|
|
new ContentsCommand($this->fullName(), $path) |
62
|
|
|
) |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function communityHealth(): PromiseInterface |
67
|
|
|
{ |
68
|
|
|
return $this->handleCommand( |
69
|
|
|
new CommunityHealthCommand($this->fullName()) |
70
|
|
|
); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function tags(): ObservableInterface |
74
|
|
|
{ |
75
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
76
|
|
|
new TagsCommand($this->fullName()) |
77
|
|
|
)); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function releases(): ObservableInterface |
81
|
|
|
{ |
82
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
83
|
|
|
new ReleasesCommand($this->fullName()) |
84
|
|
|
)); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|