1 | <?php declare(strict_types=1); |
||
18 | final class AsyncClient implements AsyncClientInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var ClientInterface |
||
22 | */ |
||
23 | private $client; |
||
24 | |||
25 | /** |
||
26 | * Create a new AsyncClient based on the loop and other options pass |
||
27 | * |
||
28 | * @param LoopInterface $loop |
||
29 | * @param string $token Instructions to fetch the token: https://blog.travis-ci.com/2013-01-28-token-token-token/ |
||
30 | * @param array $options |
||
31 | * @return AsyncClient |
||
32 | */ |
||
33 | 1 | public static function create( |
|
42 | |||
43 | /** |
||
44 | * Create an AsyncClient from a ApiClients\Foundation\ClientInterface. |
||
45 | * Be sure to pass in a client with the options from ApiSettings and the Async namespace suffix. |
||
46 | * |
||
47 | * @param ClientInterface $client |
||
48 | * @return AsyncClient |
||
49 | */ |
||
50 | 8 | public static function createFromClient(ClientInterface $client): self |
|
54 | |||
55 | /** |
||
56 | * @param ClientInterface $client |
||
57 | */ |
||
58 | 9 | private function __construct(ClientInterface $client) |
|
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | 1 | public function repository(string $repository): CancellablePromiseInterface |
|
70 | |||
71 | /** |
||
72 | * Warning this a intensive operation as it has to make a call for each hook |
||
73 | * to turn it into a Repository!!! |
||
74 | * |
||
75 | * Take a look at examples/repositories-async.php on how to limit the amount of |
||
76 | * concurrent requests. |
||
77 | * |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function repositories(callable $filter = null): ObservableInterface |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | 1 | public function user(): PromiseInterface |
|
101 | { |
||
102 | 1 | return $this->client->handle(new Command\UserCommand()); |
|
103 | } |
||
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | */ |
||
108 | 1 | public function sshKey(int $id): PromiseInterface |
|
112 | |||
113 | /** |
||
114 | * @return ObservableInterface |
||
115 | */ |
||
116 | 1 | public function hooks(): ObservableInterface |
|
117 | { |
||
118 | 1 | return unwrapObservableFromPromise($this->client->handle( |
|
119 | 1 | new Command\HooksCommand() |
|
120 | )); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * {@inheritdoc} |
||
125 | */ |
||
126 | 1 | public function accounts(): ObservableInterface |
|
127 | { |
||
128 | 1 | return unwrapObservableFromPromise($this->client->handle( |
|
129 | 1 | new Command\AccountsCommand() |
|
130 | )); |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | */ |
||
136 | 1 | public function broadcasts(): ObservableInterface |
|
142 | } |
||
143 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: