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.
Test Failed
Push — master ( c51706...f968f3 )
by Anton
01:54
created

ProcessRunner::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22

Duplication

Lines 5
Ratio 22.73 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 5
loc 22
ccs 0
cts 11
cp 0
crap 6
rs 9.568
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
    public function __construct(ProcessOutputPrinter $pop)
22
    {
23
        $this->pop = $pop;
24
    }
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
    public function run($hostname, string $command, array $config = [])
38
    {
39
        $defaults = [
40
            'timeout' => Deployer::getDefault('default_timeout', 300),
41
            'tty' => false,
42
        ];
43
        $config = array_merge($defaults, $config);
44
45
        $this->pop->command($hostname, $command);
46
47 View Code Duplication
        if (method_exists('Process', 'fromShellCommandline')) {
48
            $process = Process::fromShellCommandline($command);
49
        } else {
50
            $process = new Process($command);
51
        }
52
        $process
53
            ->setTimeout($config['timeout'])
54
            ->setTty($config['tty'])
55
            ->mustRun($this->pop->callback($hostname));
56
57
        return $process->getOutput();
58
    }
59
}
60