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.
Completed
Push — master ( e2875b...35ced9 )
by Anton
03:41
created

WorkerCommand::execute()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 2
dl 0
loc 26
ccs 0
cts 14
cp 0
crap 12
rs 9.504
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\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'));
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