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.
Passed
Push — master ( fba8ee...5e9ebc )
by Anton
02:06
created

Planner   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 62
ccs 0
cts 40
cp 0
rs 10
c 0
b 0
f 0
wmc 10
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
B commit() 0 24 7
A render() 0 4 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\Executor;
9
10
use Deployer\Exception\Exception;
11
use Deployer\Exception\RunException;
12
use Deployer\Host\Host;
13
use Deployer\Task\Task;
14
use Symfony\Component\Console\Helper\Table;
15
use Symfony\Component\Console\Helper\TableStyle;
16
use Symfony\Component\Console\Input\Input;
17
use Symfony\Component\Console\Output\Output;
18
use Symfony\Component\Console\Output\OutputInterface;
19
use Throwable;
20
21
class Planner
22
{
23
    /**
24
     * @var Table
25
     */
26
    private $table;
27
28
    private $template;
29
30
    /**
31
     * Planner constructor.
32
     *
33
     * @param OutputInterface $output
34
     * @param Host[] $hosts
35
     */
36
    public function __construct(OutputInterface $output, $hosts)
37
    {
38
        $headers = [];
39
        $this->template = [];
40
        foreach ($hosts as $host) {
41
            $headers[] = $host->tag();
42
            $this->template[] = $host->alias();
43
        }
44
        $this->table = new Table($output);
45
        $this->table->setHeaders($headers);
46
        $this->table->setStyle('box');
47
    }
48
49
    /**
50
     * @param Host[] $hosts
51
     * @param Task $task
52
     */
53
    public function commit(array $hosts, Task $task)
54
    {
55
        if (count($hosts) === 1 && $hosts[0]->alias() === 'localhost') {
56
            $row = [];
57
            foreach ($this->template as $alias) {
58
                $row[] = "-";
59
            }
60
            $row[] = $task->getName() . " (local)";
61
            $this->table->addRow($row);
62
            return;
63
        }
64
        $row = [];
65
        foreach ($this->template as $alias) {
66
            $on = "-";
67
            foreach ($hosts as $host) {
68
                if ($alias === $host->alias()) {
69
                    $on = $task->getName();
70
                    break;
71
                }
72
            }
73
            $row[] = $on;
74
        }
75
        $this->table->addRow($row);
76
    }
77
78
    public function render()
79
    {
80
        $this->table->render();
81
    }
82
}
83