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
Push — master ( 4bf09f...ac3f28 )
by Gilles
02:37
created

Pool::__invoke()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 17
ccs 10
cts 10
cp 1
rs 9.4285
cc 3
eloc 9
nc 2
nop 0
crap 3
1
<?php
2
3
namespace FunctionalPHP\Trampoline;
4
5
class Pool
6
{
7
    /** @var  callable|\Closure $f */
8
    private $f;
9
10
    /** @var  array $arguments_pool */
11
    private $arguments_pool = [];
12
13
    /** @var bool currently recursing */
14
    private $recursing = false;
15
16
    /**
17
     * @param callable $f
18
     */
19
    protected function __construct(callable $f)
20
    {
21 1
        if($f instanceof \Closure) {
22 1
            $this->f = $f->bindTo($this);
23 1
        } elseif(method_exists('\Closure','fromCallable')) {
24
            $this->f = \Closure::fromCallable($f)->bindTo($this);
25
        } else {
26 1
            throw new \RuntimeException('Using anything else than a callable is only possible for PHP >= 7.1.');
27
        }
28 1
    }
29
30
    /**
31
     * Invoke the stored function with the stored arguments.
32
     *
33
     * @return mixed
34
     */
35
    public function __invoke()
36
    {
37 1
        $result = null;
38 1
        $this->arguments_pool[] = func_get_args();
39
40 1
        if($this->recursing === false) {
41 1
            $this->recursing = true;
42
43 1
            while(! empty($this->arguments_pool)) {
44 1
                $result = call_user_func_array($this->f, array_shift($this->arguments_pool));
45 1
            }
46
47 1
            $this->recursing = false;
48 1
        }
49
50 1
        return $result;
51
    }
52
53
    /**
54
     * @param callable $f
55
     * @return callable
56
     */
57
    public static function get(callable $f)
58
    {
59 1
        return new static($f);
60
    }
61
}
62