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 ( 02c3d0...374f40 )
by Anton
02:13
created

TaskCommand::execute()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 13
nc 6
nop 2
dl 0
loc 20
ccs 15
cts 15
cp 1
crap 4
rs 9.2
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\ExecutorInterface;
12
use Deployer\Executor\ParallelExecutor;
13
use Deployer\Executor\SeriesExecutor;
14
use Symfony\Component\Console\Command\Command;
15
use Symfony\Component\Console\Input\InputInterface as Input;
16
use Symfony\Component\Console\Input\InputOption as Option;
17
use Symfony\Component\Console\Output\OutputInterface as Output;
18
19
class TaskCommand extends Command
20
{
21
    /**
22
     * @var Deployer
23
     */
24
    private $deployer;
25
26
    /**
27
     * @var ExecutorInterface
28
     */
29
    public $executor;
30
31
    /**
32
     * @param string $name
33
     * @param string $description
34
     * @param Deployer $deployer
35
     */
36 15
    public function __construct($name, $description, Deployer $deployer)
37
    {
38 15
        parent::__construct($name);
39 15
        $this->setDescription($description);
40 15
        $this->deployer = $deployer;
41 15
    }
42
43
    /**
44
     * Configures the command
45
     */
46 15
    protected function configure()
47
    {
48 15
        $this->addOption(
49 15
            'parallel',
50 15
            'p',
51 15
            Option::VALUE_NONE,
52
            'Run tasks in parallel.'
53 15
        );
54 15
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 15
    protected function execute(Input $input, Output $output)
60
    {
61 15
        $stage = $input->hasArgument('stage') ? $input->getArgument('stage') : null;
62 15
63 15
        $tasks = $this->deployer->getScriptManager()->getTasks($this->getName(), $stage);
64 15
        $servers = $this->deployer->getStageStrategy()->getServers($stage);
65
        $environments = iterator_to_array($this->deployer->environments);
66 15
67
        if (isset($this->executor)) {
68 15
            $executor = $this->executor;
69
        } else {
70 15
            if ($input->getOption('parallel')) {
71
                $executor = new ParallelExecutor($this->deployer->getConsole()->getUserDefinition());
72 15
            } else {
73 1
                $executor = new SeriesExecutor();
74 1
            }
75 15
        }
76 2
77 2
        $executor->run($tasks, $servers, $environments, $input, $output);
78 12
    }
79
}
80