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.

Planner   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 28
dl 0
loc 60
c 1
b 0
f 0
rs 10
ccs 0
cts 39
cp 0
wmc 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 3 1
B commit() 0 23 7
A __construct() 0 11 2
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->getTag();
42
            $this->template[] = $host->getAlias();
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]->getAlias() === '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->getAlias()) {
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