1 | <?php |
||
16 | final class Client implements ClientInterface |
||
17 | { |
||
18 | /** |
||
19 | * @var LoopInterface |
||
20 | */ |
||
21 | private $loop; |
||
22 | |||
23 | /** |
||
24 | * @var AsyncClientInterface |
||
25 | */ |
||
26 | private $asyncClient; |
||
27 | |||
28 | /** |
||
29 | * Create a new AsyncClient based on the loop and other options pass |
||
30 | * |
||
31 | * @param string $token Instructions to fetch the token: https://blog.travis-ci.com/2013-01-28-token-token-token/ |
||
32 | * @param array $options |
||
33 | * @return Client |
||
34 | */ |
||
35 | 1 | public static function create( |
|
45 | |||
46 | /** |
||
47 | * Create an Client from a AsyncClientInterface. |
||
48 | * Be sure to pass in a client with the options from ApiSettings and the Sync namespace suffix, |
||
49 | * and pass in the same loop as associated with the AsyncClient you're passing in. |
||
50 | * |
||
51 | * @param LoopInterface $loop |
||
52 | * @param AsyncClientInterface $asyncClient |
||
53 | * @return Client |
||
54 | */ |
||
55 | 10 | public static function createFromClient(LoopInterface $loop, AsyncClientInterface $asyncClient): self |
|
56 | { |
||
57 | 10 | return new self($loop, $asyncClient); |
|
58 | } |
||
59 | |||
60 | /** |
||
61 | * @param LoopInterface $loop |
||
62 | * @param AsyncClientInterface $asyncClient |
||
63 | */ |
||
64 | 10 | private function __construct(LoopInterface $loop, AsyncClientInterface $asyncClient) |
|
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | 1 | public function repository(string $repository): RepositoryInterface |
|
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | 1 | public function user(): UserInterface |
|
91 | |||
92 | /** |
||
93 | * {@inheritdoc} |
||
94 | */ |
||
95 | 1 | public function sshKey(int $id): SSHKeyInterface |
|
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | 1 | public function hooks(): array |
|
107 | { |
||
108 | 1 | return await( |
|
109 | 1 | Promise::fromObservable( |
|
110 | 1 | $this->asyncClient->hooks()->toArray() |
|
111 | ), |
||
112 | 1 | $this->loop |
|
113 | ); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Warning this a intensive operation as it has to make a call for each hook |
||
118 | * to turn it into a Repository!!! |
||
119 | * |
||
120 | * Take a look at examples/repositories-async.php on how to limit the amount of |
||
121 | * concurrent requests. |
||
122 | * |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | 2 | public function repositories(callable $filter = null): array |
|
126 | { |
||
127 | 2 | return await( |
|
128 | 2 | Promise::fromObservable( |
|
129 | 2 | $this->asyncClient->repositories($filter)->toArray() |
|
130 | ), |
||
131 | 2 | $this->loop |
|
132 | ); |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * {@inheritdoc} |
||
137 | */ |
||
138 | 1 | public function accounts(): array |
|
139 | { |
||
140 | 1 | return await( |
|
141 | 1 | Promise::fromObservable( |
|
142 | 1 | $this->asyncClient->accounts()->toArray() |
|
143 | ), |
||
144 | 1 | $this->loop |
|
145 | ); |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * {@inheritdoc} |
||
150 | */ |
||
151 | 1 | public function broadcasts(): array |
|
160 | } |
||
161 |