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.

Pool::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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