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 ( 8b5091...c51706 )
by Anton
01:50
created

ScriptManager::getTasks()   A

Complexity

Conditions 5
Paths 1

Size

Total Lines 34

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 5.005

Importance

Changes 0
Metric Value
cc 5
nc 1
nop 3
dl 0
loc 34
ccs 16
cts 17
cp 0.9412
crap 5.005
rs 9.0648
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\Task;
9
10
use Deployer\Host\Host;
11
use function Deployer\Support\array_flatten;
12
13
class ScriptManager
14
{
15
    /**
16
     * @var TaskCollection
17
     */
18
    private $tasks;
19
20
    /**
21
     * @param TaskCollection $tasks
22
     */
23 17
    public function __construct(TaskCollection $tasks)
24
    {
25 17
        $this->tasks = $tasks;
26 17
    }
27
28
    /**
29
     * Return tasks to run
30
     *
31
     * @param string $name
32
     * @param Host[] $hosts
33
     * @param bool $hooksEnabled
34
     * @return Task[]
35
     */
36 16
    public function getTasks($name, array $hosts = [], $hooksEnabled = true)
37
    {
38
        $collect = function ($name) use (&$collect, $hosts, $hooksEnabled) {
39 16
            $task = $this->tasks->get($name);
40
41 14
            if (!$task->shouldBePerformed(...array_values($hosts))) {
42
                return [];
43
            }
44
45 14
            $relatedTasks = [];
46
47 14
            if ($hooksEnabled) {
48 14
                $relatedTasks = array_merge(array_map($collect, $task->getBefore()), $relatedTasks);
49
            }
50
51 14
            if ($task instanceof GroupTask) {
52 6
                $relatedTasks = array_merge($relatedTasks, array_map($collect, $task->getGroup()));
53
            } else {
54 14
                $relatedTasks = array_merge($relatedTasks, [$task->getName()]);
55
            }
56
57 14
            if ($hooksEnabled) {
58 14
                $relatedTasks = array_merge($relatedTasks, array_map($collect, $task->getAfter()));
59
            }
60
61 14
            return $relatedTasks;
62 16
        };
63
64 16
        $script = $collect($name);
65 14
        $tasks = array_flatten($script);
66
67
        // Convert names to real tasks
68 14
        return array_map([$this->tasks, 'get'], $tasks);
69
    }
70
}
71