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
Pull Request — master (#1904)
by Anton
02:21
created

ProcessRunner::run()   A

Complexity

Conditions 2
Paths 4

Size

Total Lines 37

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 2.2738

Importance

Changes 0
Metric Value
cc 2
nc 4
nop 3
dl 0
loc 37
ccs 13
cts 22
cp 0.5909
crap 2.2738
rs 9.328
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\Component\ProcessRunner;
9
10
use Deployer\Deployer;
11
use Deployer\Component\ProcessRunner\Printer;
12
use Deployer\Exception\RunException;
13
use Deployer\Host\Host;
14
use Deployer\Logger\Logger;
15
use Symfony\Component\Process\Exception\ProcessFailedException;
16
use Symfony\Component\Process\Process;
17
18
class ProcessRunner
19
{
20
    private $pop;
21
    private $logger;
22
23 1
    public function __construct(Printer $pop, Logger $logger)
24
    {
25 1
        $this->pop = $pop;
26 1
        $this->logger = $logger;
27 1
    }
28
29
    /**
30
     * Runs a command, consider deployer global configs (timeout,...)
31
     *
32
     * @param Host $host
33
     * @param string $command
34
     * @param array $config
35
     *
36
     * @return string
37
     *
38
     */
39 1
    public function run(Host $host, string $command, array $config = []): string
40
    {
41
        $defaults = [
42 1
            'timeout' => $host->get('default_timeout', 300),
43
            'tty' => false,
44
        ];
45 1
        $config = array_merge($defaults, $config);
46
47 1
        $this->pop->command($host, $command);
48
49 1
        $terminalOutput = $this->pop->callback($host);
50
        $callback = function ($type, $buffer) use ($host, $terminalOutput) {
51 1
            $this->logger->printBuffer($host, $type, $buffer);
52 1
            $terminalOutput($type, $buffer);
53 1
        };
54
55
        try {
56 1
            $process = Process::fromShellCommandline($command);
57
            $process
58 1
                ->setTimeout($config['timeout'])
59 1
                ->setTty($config['tty'])
60 1
                ->mustRun($callback);
61
62 1
            return $process->getOutput();
63
        } catch (ProcessFailedException $exception) {
64
            $trace = debug_backtrace();
65
            throw new RunException(
66
                basename($trace[1]['file']),
67
                $trace[1]['line'],
68
                $host->alias(),
69
                $command,
70
                $process->getExitCode(),
71
                $process->getOutput(),
72
                $process->getErrorOutput()
73
            );
74
        }
75
    }
76
}
77