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 ( 09a43c...4f79d5 )
by Anton
03:00
created

WorkerCommand   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 77.14%

Importance

Changes 0
Metric Value
dl 0
loc 54
ccs 27
cts 35
cp 0.7714
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A configure() 0 9 1
B execute() 0 35 6
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 6
    public function __construct(Deployer $deployer)
24
    {
25 6
        parent::__construct('worker', null, $deployer);
26 6
        $this->setHidden(true);
27 6
    }
28
29 6
    protected function configure()
30
    {
31 6
        $this->addArgument('worker-task', InputArgument::REQUIRED);
32 6
        $this->addArgument('worker-host', InputArgument::REQUIRED);
33 6
        $this->addArgument('config-directory', InputArgument::REQUIRED);
34 6
        $this->addArgument('original-task', InputArgument::REQUIRED);
35 6
        $this->addOption('decorated', null, Option::VALUE_NONE);
36 6
        parent::configure();
37 6
    }
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
            $this->deployer->messenger->endOnHost($host);
64 1
            $host->getConfig()->save();
65 1
            return 0;
66
        } catch (GracefulShutdownException $e) {
67
            $this->deployer->messenger->renderException($e, $host);
68
            return GracefulShutdownException::EXIT_CODE;
69
        } catch (\Throwable $e) {
70
            $this->deployer->messenger->renderException($e, $host);
71
            return 255;
72
        }
73
    }
74
}
75