GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( f968f3...d9c744 )
by Anton
02:00
created

ProcessRunner::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 23

Duplication

Lines 5
Ratio 21.74 %

Code Coverage

Tests 10
CRAP Score 2.003

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 5
loc 23
ccs 10
cts 11
cp 0.9091
crap 2.003
rs 9.552
c 0
b 0
f 0
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Utility;
9
10
use Deployer\Deployer;
11
use Symfony\Component\Process\Exception\ProcessFailedException;
12
use Symfony\Component\Process\Process;
13
14
class ProcessRunner
15
{
16
    /**
17
     * @var ProcessOutputPrinter
18
     */
19
    private $pop;
20
21 10
    public function __construct(ProcessOutputPrinter $pop)
22
    {
23 10
        $this->pop = $pop;
24 10
    }
25
26
    /**
27
     * Runs a command, consider deployer global configs (timeout,...)
28
     *
29
     * @param string $hostname
30
     * @param string $command
31
     * @param array $config
32
     *
33
     * @return string
34
     *
35
     * @throws ProcessFailedException When the process does not return a 0 exit code.
36
     */
37 10
    public function run($hostname, string $command, array $config = [])
38
    {
39
        $defaults = [
40 10
            'timeout' => Deployer::getDefault('default_timeout', 300),
41
            'tty' => false,
42
        ];
43 10
        $config = array_merge($defaults, $config);
44
45 10
        $this->pop->command($hostname, $command);
46
47 10 View Code Duplication
        if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
48 10
            $process = Process::fromShellCommandline($command);
49
        } else {
50
            $process = new Process($command);
51
        }
52
53
        $process
54 10
            ->setTimeout($config['timeout'])
55 10
            ->setTty($config['tty'])
56 10
            ->mustRun($this->pop->callback($hostname));
57
58 10
        return $process->getOutput();
59
    }
60
}
61