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 (#1470)
by Markus
03:01 queued 51s
created

Application   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 147
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 7

Test Coverage

Coverage 74.51%

Importance

Changes 0
Metric Value
dl 0
loc 147
ccs 38
cts 51
cp 0.7451
rs 10
c 0
b 0
f 0
wmc 18
lcom 3
cbo 7

10 Methods

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