Completed
Push — master ( 8b8afe...5f2bbe )
by Greg
02:21
created

src/Common/ProcessExecutor.php (1 issue)

Upgrade to new PHP Analysis Engine

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
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)
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