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   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 10.87 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 5
loc 46
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 5 22 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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