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 ( fba8ee...5e9ebc )
by Anton
02:06
created

WorkerCommand::execute()   B

Complexity

Conditions 7
Paths 56

Size

Total Lines 37

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 8.8142

Importance

Changes 0
Metric Value
cc 7
nc 56
nop 2
dl 0
loc 37
ccs 16
cts 24
cp 0.6667
crap 8.8142
rs 8.3946
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\Collection\PersistentCollection;
11
use Deployer\Deployer;
12
use Deployer\Exception\Exception;
13
use Deployer\Exception\GracefulShutdownException;
14
use Deployer\Exception\NonFatalException;
15
use Deployer\Task\Context;
16
use Symfony\Component\Console\Input\InputArgument;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Input\InputOption as Option;
19
use Symfony\Component\Console\Output\OutputInterface;
20
21
class WorkerCommand extends MainCommand
22
{
23 9
    public function __construct(Deployer $deployer)
24
    {
25 9
        parent::__construct('worker', null, $deployer);
26 9
        $this->setHidden(true);
27 9
    }
28
29 9
    protected function configure()
30
    {
31 9
        $this->addArgument('worker-task', InputArgument::REQUIRED);
32 9
        $this->addArgument('worker-host', InputArgument::REQUIRED);
33 9
        $this->addArgument('config-directory', InputArgument::REQUIRED);
34 9
        $this->addArgument('original-task', InputArgument::REQUIRED);
35 9
        $this->addOption('decorated', null, Option::VALUE_NONE);
36 9
        parent::configure();
37 9
    }
38
39 1
    protected function execute(InputInterface $input, OutputInterface $output)
40
    {
41 1
        $this->deployer->input = $input;
42 1
        $this->deployer->output = $output;
43
44 1
        $output->setDecorated($input->getOption('decorated'));
45 1
        if (!$output->isDecorated() && !defined('NO_ANSI')) {
46
            define('NO_ANSI', 'true');
47
        }
48
49 1
        $host = $this->deployer->hosts->get($input->getArgument('worker-host'));
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument('worker-host') targeting Symfony\Component\Consol...nterface::getArgument() can also be of type array<integer,string> or null; however, Deployer\Collection\Collection::get() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
50 1
        $task = $this->deployer->tasks->get($input->getArgument('worker-task'));
51
52 1
        $this->deployer->config->set('config_directory', $input->getArgument('config-directory'));
53 1
        $host->getConfig()->load();
54
55 1
        foreach ($host->getConfig() as $name => $value) {
56
            $this->deployer->config->set($name, $value);
57
        }
58
59
        try {
60 1
            Exception::setTaskSourceLocation($task->getSourceLocation());
61 1
            $task->run(new Context($host, $input, $output));
62
63 1
            if ($task->getName() !== 'connect') {
64 1
                $this->deployer->messenger->endOnHost($host);
65
            }
66 1
            $host->getConfig()->save();
67 1
            return 0;
68
        } catch (GracefulShutdownException $e) {
69
            $this->deployer->messenger->renderException($e, $host);
70
            return GracefulShutdownException::EXIT_CODE;
71
        } catch (\Throwable $e) {
72
            $this->deployer->messenger->renderException($e, $host);
73
            return 255;
74
        }
75
    }
76
}
77