These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Robo\Common; |
||
4 | |||
5 | use Psr\Log\LoggerAwareInterface; |
||
6 | use Robo\Contract\ConfigAwareInterface; |
||
7 | use Robo\Contract\OutputAwareInterface; |
||
8 | use Robo\Contract\VerbosityThresholdInterface; |
||
9 | use Symfony\Component\Process\Process; |
||
10 | |||
11 | class ProcessExecutor implements ConfigAwareInterface, LoggerAwareInterface, OutputAwareInterface, VerbosityThresholdInterface |
||
12 | { |
||
13 | use ExecTrait; |
||
14 | use TaskIO; // uses LoggerAwareTrait and ConfigAwareTrait |
||
15 | use ProgressIndicatorAwareTrait; |
||
16 | use OutputAwareTrait; |
||
17 | |||
18 | /** |
||
19 | * @param Process $process |
||
20 | * @return type |
||
21 | */ |
||
22 | public function __construct(Process $process) |
||
23 | { |
||
24 | $this->process = $process; |
||
25 | } |
||
26 | |||
27 | View Code Duplication | public static function create($container, $process) |
|
0 ignored issues
–
show
|
|||
28 | { |
||
29 | $processExecutor = new self($process); |
||
30 | |||
31 | $processExecutor->setLogger($container->get('logger')); |
||
32 | $processExecutor->setProgressIndicator($container->get('progressIndicator')); |
||
33 | $processExecutor->setConfig($container->get('config')); |
||
34 | $processExecutor->setOutputAdapter($container->get('outputAdapter')); |
||
35 | |||
36 | return $processExecutor; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @return string |
||
41 | */ |
||
42 | protected function getCommandDescription() |
||
43 | { |
||
44 | return $this->process->getCommandLine(); |
||
45 | } |
||
46 | |||
47 | public function run() |
||
48 | { |
||
49 | return $this->execute($this->process); |
||
50 | } |
||
51 | } |
||
52 |
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.