These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php declare(strict_types=1); |
||
2 | |||
3 | namespace ApiClients\Client\Travis\CommandBus\Handler; |
||
4 | |||
5 | use ApiClients\Client\Travis\CommandBus\Command\VarsCommand; |
||
6 | use ApiClients\Client\Travis\Resource\EnvironmentVariableInterface; |
||
7 | use ApiClients\Tools\Services\Client\FetchAndHydrateService; |
||
8 | use ApiClients\Tools\Services\Client\FetchAndIterateService; |
||
9 | use React\Promise\PromiseInterface; |
||
10 | use function React\Promise\resolve; |
||
11 | |||
12 | View Code Duplication | final class VarsHandler |
|
0 ignored issues
–
show
|
|||
13 | { |
||
14 | /** |
||
15 | * @var FetchAndHydrateService |
||
16 | */ |
||
17 | private $service; |
||
18 | |||
19 | /** |
||
20 | * @param FetchAndIterateService $service |
||
21 | */ |
||
22 | 1 | public function __construct(FetchAndIterateService $service) |
|
23 | { |
||
24 | 1 | $this->service = $service; |
|
25 | 1 | } |
|
26 | |||
27 | /** |
||
28 | * Fetch the given repository and hydrate it. |
||
29 | * |
||
30 | * @param VarsCommand $command |
||
31 | * @return PromiseInterface |
||
32 | */ |
||
33 | 1 | public function handle(VarsCommand $command): PromiseInterface |
|
34 | { |
||
35 | 1 | return resolve($this->service->iterate( |
|
36 | 1 | 'settings/env_vars?repository_id=' . (string)$command->getRepositoryId(), |
|
37 | 1 | 'env_vars', |
|
38 | 1 | EnvironmentVariableInterface::HYDRATE_CLASS |
|
39 | )); |
||
40 | } |
||
41 | } |
||
42 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.