1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace WyriHaximus\Travis\Resource\Sync; |
5
|
|
|
|
6
|
|
|
use WyriHaximus\ApiClient\Resource\CallAsyncTrait; |
7
|
|
|
use WyriHaximus\Travis\Resource\Repository as BaseRepository; |
8
|
|
|
use function Clue\React\Block\await; |
9
|
|
|
use function React\Promise\resolve; |
10
|
|
|
use WyriHaximus\Travis\Resource\SettingsInterface; |
11
|
|
|
use WyriHaximus\Travis\Resource\RepositoryKeyInterface; |
12
|
|
|
|
13
|
|
|
class Repository extends BaseRepository |
14
|
|
|
{ |
15
|
|
|
use CallAsyncTrait; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @return array |
19
|
|
|
*/ |
20
|
|
|
public function builds(): array |
21
|
|
|
{ |
22
|
|
|
return $this->wait($this->observableToPromise($this->callAsync('builds')->toArray())); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param int $id |
27
|
|
|
* @return Build |
28
|
|
|
*/ |
29
|
|
|
public function build(int $id): Build |
30
|
|
|
{ |
31
|
|
|
return $this->wait($this->callAsync('build', $id)); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return array |
36
|
|
|
*/ |
37
|
|
|
public function commits(): array |
38
|
|
|
{ |
39
|
|
|
return $this->wait($this->observableToPromise($this->callAsync('commits')->toArray())); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return SettingsInterface |
44
|
|
|
*/ |
45
|
|
|
public function settings(): SettingsInterface |
46
|
|
|
{ |
47
|
|
|
return $this->wait($this->callAsync('settings')); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return bool |
52
|
|
|
*/ |
53
|
|
|
public function isActive(): bool |
54
|
|
|
{ |
55
|
|
|
return $this->wait($this->callAsync('isActive')); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return Repository |
60
|
|
|
*/ |
61
|
|
|
public function enable(): Repository |
62
|
|
|
{ |
63
|
|
|
return $this->wait($this->callAsync('enable')); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return Repository |
68
|
|
|
*/ |
69
|
|
|
public function disable(): Repository |
70
|
|
|
{ |
71
|
|
|
return $this->wait($this->callAsync('disable')); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return array |
76
|
|
|
*/ |
77
|
|
|
public function branches(): array |
78
|
|
|
{ |
79
|
|
|
return $this->wait($this->observableToPromise($this->callAsync('branches')->toArray())); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return array |
84
|
|
|
*/ |
85
|
|
|
public function vars(): array |
86
|
|
|
{ |
87
|
|
|
return $this->wait($this->observableToPromise($this->callAsync('vars')->toArray())); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return array |
92
|
|
|
*/ |
93
|
|
|
public function caches(): array |
94
|
|
|
{ |
95
|
|
|
return $this->wait($this->observableToPromise($this->callAsync('caches')->toArray())); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @return RepositoryKeyInterface |
100
|
|
|
*/ |
101
|
|
|
public function key(): RepositoryKeyInterface |
102
|
|
|
{ |
103
|
|
|
return $this->wait($this->callAsync('key')); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return Repository |
108
|
|
|
*/ |
109
|
|
|
public function refresh(): Repository |
110
|
|
|
{ |
111
|
|
|
return $this->wait($this->callAsync('refresh')); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|