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.

WorkerCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
nc 1
nop 1
dl 0
loc 4
c 0
b 0
f 0
cc 1
rs 10
ccs 3
cts 3
cp 1
crap 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\Deployer;
11
use Deployer\Executor\Worker;
12
use Symfony\Component\Console\Input\InputArgument;
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Input\InputOption as Option;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
class WorkerCommand extends MainCommand
18
{
19 12
    public function __construct(Deployer $deployer)
20
    {
21 12
        parent::__construct('worker', null, $deployer);
22 12
        $this->setHidden(true);
23 12
    }
24
25 12
    protected function configure()
26
    {
27 12
        $this->addArgument('worker-task', InputArgument::REQUIRED);
28 12
        $this->addArgument('worker-host', InputArgument::REQUIRED);
29 12
        $this->addArgument('master-port', InputArgument::REQUIRED);
30 12
        $this->addArgument('original-task', InputArgument::REQUIRED); // added as stringing $input adds own args
31 12
        $this->addOption('decorated', null, Option::VALUE_NONE);
32 12
        parent::configure();
33 12
    }
34
35
    protected function execute(InputInterface $input, OutputInterface $output)
36
    {
37
        $this->deployer->input = $input;
38
        $this->deployer->output = $output;
39
40
        $output->setDecorated($input->getOption('decorated'));
41
        if (!$output->isDecorated() && !defined('NO_ANSI')) {
42
            define('NO_ANSI', 'true');
43
        }
44
45
        $this->deployer->config->set('master_url', 'http://localhost:' . $input->getArgument('master-port'));
0 ignored issues
show
Bug introduced by
Are you sure $input->getArgument('master-port') of type null|string|string[] can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

45
        $this->deployer->config->set('master_url', 'http://localhost:' . /** @scrutinizer ignore-type */ $input->getArgument('master-port'));
Loading history...
46
47
        $task = $this->deployer->tasks->get($input->getArgument('worker-task'));
48
        $host = $this->deployer->hosts->get($input->getArgument('worker-host'));
49
        $host->config()->load();
50
51
        // TODO: Maybe relevant to leave this code. Was here when loading from config file was.
52
//        foreach ($host->getConfig() as $name => $value) {
53
//            $this->deployer->config->set($name, $value);
54
//        }
55
        $worker = new Worker($this->deployer);
56
        $exitCode = $worker->execute($task, $host);
57
58
        $host->config()->save();
59
        return $exitCode;
60
    }
61
}
62