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 ( 16e9eb...57fd75 )
by Anton
02:18
created

TaskCommand   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 10

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 78
ccs 29
cts 29
cp 1
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A configure() 0 9 1
C execute() 0 37 7
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 Monolog\Logger;
15
use Symfony\Component\Console\Command\Command;
16
use Symfony\Component\Console\Input\InputInterface as Input;
17
use Symfony\Component\Console\Input\InputOption as Option;
18
use Symfony\Component\Console\Output\OutputInterface as Output;
19
20
class TaskCommand extends Command
21
{
22
    /**
23
     * @var Deployer
24
     */
25
    private $deployer;
26
27
    /**
28
     * @var ExecutorInterface
29
     */
30
    public $executor;
31
32
    /**
33
     * @param string $name
34
     * @param string $description
35
     * @param Deployer $deployer
36 15
     */
37
    public function __construct($name, $description, Deployer $deployer)
38 15
    {
39 15
        parent::__construct($name);
40 15
        $this->setDescription($description);
41 15
        $this->deployer = $deployer;
42
    }
43
44
    /**
45
     * Configures the command
46 15
     */
47
    protected function configure()
48 15
    {
49 15
        $this->addOption(
50 15
            'parallel',
51 15
            'p',
52
            Option::VALUE_NONE,
53 15
            'Run tasks in parallel.'
54 15
        );
55
    }
56
57
    /**
58
     * {@inheritdoc}
59 15
     */
60
    protected function execute(Input $input, Output $output)
61 15
    {
62 15
        $stage = $input->hasArgument('stage') ? $input->getArgument('stage') : null;
63 15
64 15
        $tasks = $this->deployer->getScriptManager()->getTasks($this->getName(), $stage);
65
        $servers = $this->deployer->getStageStrategy()->getServers($stage);
66 15
        $environments = iterator_to_array($this->deployer->environments);
67
68 15
        if (isset($this->executor)) {
69
            $executor = $this->executor;
70 15
        } else {
71
            if ($input->getOption('parallel')) {
72 15
                $executor = new ParallelExecutor($this->deployer->getConsole()->getUserDefinition());
73 1
            } else {
74 1
                $executor = new SeriesExecutor();
75 15
            }
76 2
        }
77 2
78 12
        try {
79
            $executor->run($tasks, $servers, $environments, $input, $output);
80
        } catch (\Exception $exception) {
81
            \Deployer\logger($exception->getMessage(), Logger::ERROR);
82 15
83 15
            // Check if we have tasks to execute on failure.
84
            if ($this->deployer['onFailure']->has($this->getName())) {
85
                $taskName = $this->deployer['onFailure']->get($this->getName());
86
                $tasks = $this->deployer->getScriptManager()->getTasks($taskName, $stage);
87
                $executor->run($tasks, $servers, $environments, $input, $output);
88
            }
89
90
            throw $exception;
91
        }
92
93
        if (Deployer::hasDefault('terminate_message')) {
94
            $output->writeln(Deployer::getDefault('terminate_message'));
95
        }
96
    }
97
}
98