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.
Completed
Pull Request — master (#13)
by Jérémy
03:43 queued 01:52
created

WaterfallTrait::waterfall()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 2
eloc 9
nc 1
nop 1
1
<?php
2
3
namespace CapMousse\ReactRestify\Traits;
4
5
trait WaterfallTrait {
6
    /**
7
     * Call callback one
8
     * @param  \Closure $fn 
9
     * @return \Closure
10
     */
11
    private function callOnce ($fn) 
12
    {
13
        return function () use ($fn) {
14
            if ($fn === null) return;
15
            call_user_func($fn, func_get_args());
16
            $fn = null;
1 ignored issue
show
Unused Code introduced by
$fn is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
17
        };
18
    }
19
20
    /**
21
     * Run tasks in series
22
     * @param  array  $tasks 
23
     * @return void
24
     */
25
    private function waterfall (array $tasks)
26
    {
27
        $index = 0;
28
29
        $next = function () use (&$index, &$tasks, &$next) {
30
            if ($index == count($tasks)) { 
31
                return;
32
            }
33
            
34
            $callback = $this->callOnce(function () use (&$next) {
35
                $next();
36
            });
37
38
            call_user_func($tasks[$index++], $callback);
39
        };
40
41
        $next();
42
    }
43
}