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

Application::getDefaultInputDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 10
ccs 5
cts 5
cp 1
crap 1
rs 9.9332
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\Console;
9
10
use Deployer\Component\PharUpdate\Console\Command as PharUpdateCommand;
11
use Deployer\Component\PharUpdate\Console\Helper as PharUpdateHelper;
12
use Deployer\Deployer;
13
use Symfony\Component\Console\Application as Console;
14
use Symfony\Component\Console\Command\Command;
15
use Symfony\Component\Console\Input\InputDefinition;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Input\InputOption;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
class Application extends Console
21
{
22
    /**
23
     * Input definition for user specific arguments and options.
24
     *
25
     * @var InputDefinition
26
     */
27
    private $userDefinition;
28
29
    /**
30
     * @var callable
31
     */
32
    private $catchIO;
33
34
    /**
35
     * @var callable
36
     */
37
    private $after;
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 4
    protected function getDefaultInputDefinition()
43
    {
44 4
        $inputDefinition = parent::getDefaultInputDefinition();
45
46 4
        $inputDefinition->addOption(
47 4
            new InputOption('--file', '-f', InputOption::VALUE_OPTIONAL, 'Specify Deployer file')
48
        );
49
50 4
        return $inputDefinition;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 4
    protected function getDefaultCommands()
57
    {
58 4
        $commands = parent::getDefaultCommands();
59
60 4
        if ($this->isPharArchive()) {
61
            $commands[] = $this->selfUpdateCommand();
62
        }
63
64 4
        return $commands;
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    private function selfUpdateCommand()
71
    {
72
        $selfUpdate = new PharUpdateCommand('self-update');
73
        $selfUpdate->setDescription('Updates deployer.phar to the latest version');
74
        $selfUpdate->setManifestUri('https://deployer.org/manifest.json');
75
        return $selfUpdate;
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81 4
    protected function getDefaultHelperSet()
82
    {
83 4
        $helperSet = parent::getDefaultHelperSet();
84
85 4
        if ($this->isPharArchive()) {
86
            $helperSet->set(new PharUpdateHelper());
87
        }
88 4
        return $helperSet;
89
    }
90
91
    /**
92
     * @return InputDefinition
93
     */
94 4
    public function getUserDefinition()
95
    {
96 4
        if (null === $this->userDefinition) {
97 4
            $this->userDefinition = new InputDefinition();
98
        }
99
100 4
        return $this->userDefinition;
101
    }
102
103
    /**
104
     * Add user definition arguments and options to definition.
105
     */
106 4
    public function addUserArgumentsAndOptions()
107
    {
108 4
        $this->getDefinition()->addArguments($this->getUserDefinition()->getArguments());
109 4
        $this->getDefinition()->addOptions($this->getUserDefinition()->getOptions());
110 4
    }
111
112
    /**
113
     * @return bool
114
     */
115 4
    public function isPharArchive()
116
    {
117 4
        return 'phar:' === substr(__FILE__, 0, 5);
118
    }
119
120
    /**
121
     * {@inheritdoc}
122
     */
123 3
    protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
124
    {
125 3
        $exception = null;
126 3
        $exitCode = 0;
127
128 3
        if (!empty($this->catchIO)) {
129 3
            list($input, $output) = call_user_func($this->catchIO, $input, $output);
130
        }
131
132
        try {
133 3
            $exitCode = parent::doRunCommand($command, $input, $output);
134
        } catch (\Exception $x) {
135
            $exception = $x;
136
        } catch (\Throwable $x) {
137
            $exception = $x;
138
        }
139
140 3
        if (!empty($this->after)) {
141
            call_user_func($this->after, new CommandEvent($command, $input, $output, $exception, $exitCode));
142
        }
143
144 3
        if ($exception !== null) {
145
            throw $exception;
146
        }
147
148 3
        return $exitCode;
149
    }
150
151
    /**
152
     * @param $callable
153
     */
154 4
    public function catchIO($callable)
155
    {
156 4
        $this->catchIO = $callable;
157 4
    }
158
159
    /**
160
     * @param $callable
161
     */
162 4
    public function afterRun($callable)
163
    {
164 4
        $this->after = $callable;
165 4
    }
166
}
167