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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 51
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
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 \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