|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace ApiClients\Client\Github\Resource\Async; |
|
4
|
|
|
|
|
5
|
|
|
use ApiClients\Foundation\Hydrator\CommandBus\Command\HydrateCommand; |
|
6
|
|
|
use ApiClients\Foundation\Transport\CommandBus\Command\JsonDecodeCommand; |
|
7
|
|
|
use ApiClients\Foundation\Transport\CommandBus\Command\SimpleRequestCommand; |
|
8
|
|
|
use ApiClients\Foundation\Transport\Response; |
|
9
|
|
|
use ApiClients\Client\Github\CommandBus\Command\IteratePagesCommand; |
|
10
|
|
|
use ApiClients\Client\Github\Resource\User as BaseUser; |
|
11
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
12
|
|
|
use Rx\Observable; |
|
13
|
|
|
use Rx\ObservableInterface; |
|
14
|
|
|
use Rx\ObserverInterface; |
|
15
|
|
|
use Rx\React\Promise; |
|
16
|
|
|
use Rx\SchedulerInterface; |
|
17
|
|
|
|
|
18
|
|
|
class User extends BaseUser |
|
19
|
|
|
{ |
|
20
|
|
|
public function refresh() : User |
|
21
|
|
|
{ |
|
22
|
|
|
return $this->wait($this->callAsync('refresh')); |
|
|
|
|
|
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function repository(string $repository) |
|
26
|
|
|
{ |
|
27
|
|
|
return $this->getCommandBus()->handle( |
|
28
|
|
|
new SimpleRequestCommand('repos/' . $this->login() . '/' . $repository) |
|
29
|
|
|
)->then(function (ResponseInterface $response) { |
|
30
|
|
|
return $this->getCommandBus()->handle(new HydrateCommand('Repository', $response->getBody()->getJson())); |
|
|
|
|
|
|
31
|
|
|
}); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function repositories(): ObservableInterface |
|
35
|
|
|
{ |
|
36
|
|
|
return Observable::create(function ( |
|
37
|
|
|
ObserverInterface $observer, |
|
38
|
|
|
SchedulerInterface $scheduler |
|
39
|
|
|
) { |
|
40
|
|
|
$this->getCommandBus()->handle( |
|
41
|
|
|
new IteratePagesCommand('users/' . $this->login() . '/repos', $scheduler) |
|
|
|
|
|
|
42
|
|
|
)->done(function (Observable $observable) use ($observer, $scheduler) { |
|
43
|
|
|
$observable->subscribeCallback( |
|
44
|
|
|
[$observer, 'onNext'], |
|
45
|
|
|
[$observer, 'onError'], |
|
46
|
|
|
[$observer, 'onCompleted'], |
|
47
|
|
|
$scheduler |
|
48
|
|
|
); |
|
49
|
|
|
}); |
|
50
|
|
|
})->flatMap(function ($repositories) { |
|
51
|
|
|
return Observable::fromArray($repositories); |
|
52
|
|
|
})->flatMap(function ($repository) { |
|
53
|
|
|
return Promise::toObservable($this->getCommandBus()->handle(new HydrateCommand('Repository', $repository))); |
|
54
|
|
|
}); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.