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 ( 1dde54...e1b3c4 )
by Gilles
02:13
created

Pool::__invoke()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 17
ccs 8
cts 8
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 \Closure $f
18
     */
19
    protected function __construct(\Closure $f)
20
    {
21 1
        $this->f = $f->bindTo($this);
22 1
    }
23
24
    /**
25
     * Invoke the stored function with the stored arguments.
26
     *
27
     * @return mixed
28
     */
29
    public function __invoke()
30
    {
31 1
        $result = null;
32 1
        $this->arguments_pool[] = func_get_args();
33
34 1
        if($this->recursing === false) {
35 1
            $this->recursing = true;
36
37 1
            while(! empty($this->arguments_pool)) {
38 1
                $result = call_user_func_array($this->f, array_shift($this->arguments_pool));
39
            }
40
41 1
            $this->recursing = false;
42
        }
43
44 1
        return $result;
45
    }
46
47
    /**
48
     * @param \Closure $f
49
     * @return callable
50
     */
51
    public static function get(\Closure $f)
52
    {
53 1
        return new static($f);
54
    }
55
}
56