These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace ApiClients\Client\Supervisord\CommandBus\Handler\Program; |
||
6 | |||
7 | use ApiClients\Client\Supervisord\CommandBus\Command\Program\StopCommand; |
||
8 | use ApiClients\Client\Supervisord\CommandBus\Command\ProgramsCommand; |
||
9 | use ApiClients\Foundation\Hydrator\Hydrator; |
||
10 | use ApiClients\Tools\Services\XmlRpc\XmlRpcService; |
||
11 | use React\Promise\PromiseInterface; |
||
12 | |||
13 | View Code Duplication | final class StopHandler |
|
0 ignored issues
–
show
|
|||
14 | { |
||
15 | /** |
||
16 | * @var XmlRpcService |
||
17 | */ |
||
18 | private $service; |
||
19 | |||
20 | /** |
||
21 | * @var Hydrator |
||
22 | */ |
||
23 | private $hydrator; |
||
24 | |||
25 | /** |
||
26 | * @param XmlRpcService $service |
||
27 | * @param Hydrator $hydrator |
||
28 | */ |
||
29 | public function __construct(XmlRpcService $service, Hydrator $hydrator) |
||
30 | { |
||
31 | $this->service = $service; |
||
32 | $this->hydrator = $hydrator; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @param ProgramsCommand $command |
||
37 | * @return PromiseInterface |
||
38 | */ |
||
39 | public function handle(StopCommand $command): PromiseInterface |
||
40 | { |
||
41 | return $this->service->call( |
||
42 | 'supervisor.stopProcess', |
||
43 | [ |
||
44 | $command->getName(), |
||
45 | ] |
||
46 | ); |
||
47 | } |
||
48 | } |
||
49 |
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.