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   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 57
rs 10
c 1
b 0
f 1
ccs 16
cts 18
cp 0.8889
wmc 7
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A __invoke() 0 17 3
A get() 0 4 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