Passed
Push — master ( 9d4bf9...615338 )
by Radosław
02:10
created

TrampolineThunk   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Baethon\Phln;
6
7
class TrampolineThunk
8
{
9
    private \Closure $fn;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_NS_SEPARATOR, expecting T_FUNCTION or T_CONST
Loading history...
10
11
    public function __construct(callable $fn)
12
    {
13
        $this->fn = \Closure::fromCallable($fn)
14
            ->bindTo($this);
15
    }
16
17
    /**
18
     * @param array<int, mixed> ...$args
19
     * @retun \Closure
20
     */
21
    public function __invoke(...$args): \Closure
22
    {
23
        $fn = $this->fn;
24
25
        return function () use ($args, $fn) {
26
            return $fn(...$args);
27
        };
28
    }
29
}
30