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.
Test Failed
Pull Request — master (#1904)
by Anton
02:21
created

ScriptManager::getTasks()   A

Complexity

Conditions 5
Paths 1

Size

Total Lines 34

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 5.0406

Importance

Changes 0
Metric Value
cc 5
nc 1
nop 3
dl 0
loc 34
ccs 15
cts 17
cp 0.8824
crap 5.0406
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 6
    public function __construct(TaskCollection $tasks)
24
    {
25 6
        $this->tasks = $tasks;
26 6
    }
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 5
    public function getTasks($name, array $hosts = [], $hooksEnabled = true)
37
    {
38
        $collect = function ($name) use (&$collect, $hosts, $hooksEnabled) {
39 5
            $task = $this->tasks->get($name);
40
41 3
            if (!$task->shouldBePerformed(...array_values($hosts))) {
42
                return [];
43
            }
44
45 3
            $relatedTasks = [];
46
47 3
            if ($hooksEnabled) {
48 3
                $relatedTasks = array_merge(array_map($collect, $task->getBefore()), $relatedTasks);
49
            }
50
51 3
            if ($task instanceof GroupTask) {
52
                $relatedTasks = array_merge($relatedTasks, array_map($collect, $task->getGroup()));
53
            } else {
54 3
                $relatedTasks = array_merge($relatedTasks, [$task->getName()]);
55
            }
56
57 3
            if ($hooksEnabled) {
58 3
                $relatedTasks = array_merge($relatedTasks, array_map($collect, $task->getAfter()));
59
            }
60
61 3
            return $relatedTasks;
62 5
        };
63
64 5
        $script = $collect($name);
65 3
        $tasks = array_flatten($script);
66
67
        // Convert names to real tasks
68 3
        return array_map([$this->tasks, 'get'], $tasks);
69
    }
70
}
71