@@ 12-41 (lines=30) @@ | ||
9 | use React\Promise\PromiseInterface; |
|
10 | use function React\Promise\resolve; |
|
11 | ||
12 | final class BuildsHandler |
|
13 | { |
|
14 | /** |
|
15 | * @var FetchAndHydrateService |
|
16 | */ |
|
17 | private $service; |
|
18 | ||
19 | /** |
|
20 | * @param FetchAndIterateService $service |
|
21 | */ |
|
22 | public function __construct(FetchAndIterateService $service) |
|
23 | { |
|
24 | $this->service = $service; |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * Fetch the given repository and hydrate it. |
|
29 | * |
|
30 | * @param BuildsCommand $command |
|
31 | * @return PromiseInterface |
|
32 | */ |
|
33 | public function handle(BuildsCommand $command): PromiseInterface |
|
34 | { |
|
35 | return resolve($this->service->iterate( |
|
36 | 'repos/' . $command->getRepository() . '/builds', |
|
37 | 'builds', |
|
38 | BuildInterface::HYDRATE_CLASS |
|
39 | )); |
|
40 | } |
|
41 | } |
|
42 |
@@ 12-41 (lines=30) @@ | ||
9 | use React\Promise\PromiseInterface; |
|
10 | use function React\Promise\resolve; |
|
11 | ||
12 | final class CommitsHandler |
|
13 | { |
|
14 | /** |
|
15 | * @var FetchAndHydrateService |
|
16 | */ |
|
17 | private $service; |
|
18 | ||
19 | /** |
|
20 | * @param FetchAndIterateService $service |
|
21 | */ |
|
22 | public function __construct(FetchAndIterateService $service) |
|
23 | { |
|
24 | $this->service = $service; |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * Fetch the given repository and hydrate it. |
|
29 | * |
|
30 | * @param CommitsCommand $command |
|
31 | * @return PromiseInterface |
|
32 | */ |
|
33 | public function handle(CommitsCommand $command): PromiseInterface |
|
34 | { |
|
35 | return resolve($this->service->iterate( |
|
36 | 'repos/' . $command->getRepository() . '/builds', |
|
37 | 'commits', |
|
38 | CommitInterface::HYDRATE_CLASS |
|
39 | )); |
|
40 | } |
|
41 | } |
|
42 |