Completed
Pull Request — master (#546)
by Greg
02:45
created

ProcessExecutor::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 11
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 11
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 2
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
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
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
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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