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.
Passed
Push — master ( b3cd52...71bd8a )
by Anton
02:19
created

Application::addUserArgumentsAndOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
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 Symfony\Component\Console\Application as Console;
13
use Symfony\Component\Console\Command\Command;
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Input\InputOption;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
class Application extends Console
19
{
20
    private $after;
21
22
    protected function getDefaultInputDefinition()
23
    {
24
        $inputDefinition = parent::getDefaultInputDefinition();
25
26
        $inputDefinition->addOption(
27
            new InputOption('--file', '-f', InputOption::VALUE_OPTIONAL, 'Specify Deployer file')
28
        );
29
30
        return $inputDefinition;
31
    }
32
33
    protected function getDefaultCommands()
34
    {
35
        $commands = parent::getDefaultCommands();
36
37
        if ($this->isPharArchive()) {
38
            $commands[] = $this->selfUpdateCommand();
39
        }
40
41
        return $commands;
42
    }
43
44
    public function isPharArchive()
45
    {
46
        return 'phar:' === substr(__FILE__, 0, 5);
47
    }
48
49
    private function selfUpdateCommand()
50
    {
51
        $selfUpdate = new PharUpdateCommand('self-update');
52
        $selfUpdate->setDescription('Updates deployer.phar to the latest version');
53
        $selfUpdate->setManifestUri('https://deployer.org/manifest.json');
54
        return $selfUpdate;
55
    }
56
57
    protected function getDefaultHelperSet()
58
    {
59
        $helperSet = parent::getDefaultHelperSet();
60
61
        if ($this->isPharArchive()) {
62
            $helperSet->set(new PharUpdateHelper());
63
        }
64
        return $helperSet;
65
    }
66
67
    protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
68
    {
69
        $exception = null;
70
        $exitCode = 0;
71
72
        try {
73
            $exitCode = parent::doRunCommand($command, $input, $output);
74
        } catch (\Throwable $x) {
75
            $exception = $x;
76
        }
77
78
        if (!empty($this->after)) {
79
            call_user_func($this->after, new CommandEvent($command, $input, $output, $exception, $exitCode));
80
        }
81
82
        if ($exception !== null) {
83
            throw $exception;
84
        }
85
86
        return $exitCode;
87
    }
88
89
    public function afterRun($callable)
90
    {
91
        $this->after = $callable;
92
    }
93
}
94