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.

Process::isShy()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * See class comment
4
 *
5
 * PHP Version 5
6
 *
7
 * @category   Netresearch
8
 * @package    Netresearch\Kite
9
 * @subpackage Service
10
 * @author     Christian Opitz <[email protected]>
11
 * @license    http://www.netresearch.de Netresearch Copyright
12
 * @link       http://www.netresearch.de
13
 */
14
15
namespace Netresearch\Kite\Service;
16
use Netresearch\Kite\Exception\ProcessFailedException;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
/**
20
 * A shell command service
21
 * (taken from TYPO3\Surf\Domain\Service\ShellCommandService)
22
 *
23
 * @category   Netresearch
24
 * @package    Netresearch\Kite
25
 * @subpackage Service
26
 * @author     Christian Opitz <[email protected]>
27
 * @license    http://www.netresearch.de Netresearch Copyright
28
 * @link       http://www.netresearch.de
29
 */
30
class Process extends \Symfony\Component\Process\Process
31
{
32
    /**
33
     * @var \Netresearch\Kite\Service\Console
34
     */
35
    protected $console;
36
37
    /**
38
     * @var bool
39
     */
40
    protected $dryRun = false;
41
42
    /**
43
     * @var bool
44
     */
45
    protected $shy = false;
46
47
    /**
48
     * @var bool (passthrough) whether to pass command output through to console output
49
     */
50
    protected $pt = false;
51
52
    /**
53
     * Constructor.
54
     *
55
     * @param Console     $console The console
56
     * @param string      $command The command line to run
57
     * @param string|null $cwd     The working directory or null to use the
58
     *                             working dir of the current PHP process
59
     */
60
    public function __construct(Console $console, $command, $cwd = null)
61
    {
62
        $this->console = $console;
63
64
        if (is_string($command)) {
65
            $command = trim($command);
66
        } elseif (is_array($command)) {
67
            $command = implode('; ', $command);
68
        } else {
69
            throw new \Netresearch\Kite\Exception('Command must be string or array, ' . gettype($command) . ' given.', 1312454906);
70
        }
71
72
        parent::__construct($command, $cwd, null, null, null);
73
    }
74
75
76
    /**
77
     * Set dry run
78
     *
79
     * @param boolean $dryRun Dry run
80
     *
81
     * @return void
82
     */
83
    public function setDryRun($dryRun)
84
    {
85
        $this->dryRun = $dryRun;
86
    }
87
88
    /**
89
     * Get if output should not be logged to debug
90
     *
91
     * @return boolean
92
     */
93
    public function isShy()
94
    {
95
        return $this->shy;
96
    }
97
98
    /**
99
     * Set if output should not be logged to debug
100
     *
101
     * @param boolean $shy Shyness
102
     *
103
     * @return void
104
     */
105
    public function setShy($shy)
106
    {
107
        $this->shy = $shy;
108
    }
109
110
    /**
111
     * Get whether to pass command output through to console output
112
     *
113
     * @return boolean
114
     */
115
    public function isPt()
116
    {
117
        return $this->pt;
118
    }
119
120
    /**
121
     * Set whether to pass command output through to console output
122
     *
123
     * @param boolean $pt Passthru?
124
     *
125
     * @return void
126
     */
127
    public function setPt($pt)
128
    {
129
        $this->pt = $pt;
130
    }
131
132
    /**
133
     * Execute a shell command
134
     *
135
     * @param callable|null $callback A PHP callback to run whenever there is some
136
     *                                output available on STDOUT or STDERR
137
     *
138
     * @return mixed The output of the shell command or FALSE if the command returned a non-zero exit code and $ignoreErrors was enabled.
139
     */
140
    public function run($callback = null)
141
    {
142
        $command = $this->getCommandLine();
143
144
        $this->console->output('<cmd>' . $this->getWorkingDirectory() . ' > ' . $command . '</cmd>', OutputInterface::VERBOSITY_VERBOSE);
145
146
        if ($this->dryRun) {
147
            return null;
148
        }
149
150
        parent::run(
151
            function ($type, $buffer) use ($callback) {
152
                if ($callback) {
153
                    call_user_func($callback, $type, $buffer);
154
                }
155
                if (!$this->shy || $type !== self::OUT) {
156
                    $this->console->output($buffer, $this->pt ? $this->console->getVerbosity() : OutputInterface::VERBOSITY_DEBUG, false, !$this->pt);
157
                }
158
            }
159
        );
160
161
        if ($this->getExitCode() !== 0) {
162
            throw new ProcessFailedException($this);
163
        }
164
165
        return trim($this->getOutput());
166
    }
167
}
168
?>
169