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 ( b3cd52...71bd8a )
by Anton
02:19
created

ScriptManager::getTasks()   B

Complexity

Conditions 6
Paths 8

Size

Total Lines 28

Duplication

Lines 6
Ratio 21.43 %

Code Coverage

Tests 15
CRAP Score 6

Importance

Changes 0
Metric Value
cc 6
nc 8
nop 1
dl 6
loc 28
ccs 15
cts 15
cp 1
crap 6
rs 8.8497
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 function Deployer\Support\array_flatten;
11
12
class ScriptManager
13
{
14
    private $tasks;
15
    private $hooksEnabled = true;
16
17 5
    public function __construct(TaskCollection $tasks)
18
    {
19 5
        $this->tasks = $tasks;
20 5
    }
21
22
    /**
23
     * Return tasks to run.
24
     *
25
     * @return Task[]
26
     */
27 5
    public function getTasks(string $name)
28
    {
29 5
        $tasks = [];
30
31 5
        $task = $this->tasks->get($name);
32
33 3 View Code Duplication
        if ($this->hooksEnabled) {
34 3
            $tasks = array_merge(array_map([$this, 'getTasks'], $task->getBefore()), $tasks);
35
        }
36
37 3
        if ($task instanceof GroupTask) {
38 1
            foreach ($task->getGroup() as $taskName) {
39 1
                $subTasks = $this->getTasks($taskName);
40 1
                foreach ($subTasks as $subTask) {
41 1
                    $subTask->addSelector($task->getSelector());
42 1
                    $tasks[] = $subTask;
43
                }
44
            }
45
        } else {
46 3
            $tasks[] = $task;
47
        }
48
49 3 View Code Duplication
        if ($this->hooksEnabled) {
50 3
            $tasks = array_merge($tasks, array_map([$this, 'getTasks'], $task->getAfter()));
51
        }
52
53 3
        return array_flatten($tasks);
54
    }
55
56
    public function getHooksEnabled()
57
    {
58
        return $this->hooksEnabled;
59
    }
60
61
    public function setHooksEnabled($hooksEnabled): void
62
    {
63
        $this->hooksEnabled = $hooksEnabled;
64
    }
65
}
66