Test Failed
Push — master ( 50022e...5b6d46 )
by Radosław
02:04
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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __invoke() 0 8 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Baethon\Phln;
5
6
class TrampolineThunk
7
{
8
    /**
9
     * @var \Closure
10
     */
11
    private $fn;
12
13
    public function __construct(callable $fn)
14
    {
15
        $this->fn = \Closure::fromCallable($fn)
16
            ->bindTo($this);
17
    }
18
19
    public function __invoke(...$args)
20
    {
21
        $fn = $this->fn;
22
23
        return function () use ($args, $fn) {
24
            return $fn(...$args);
25
        };
26
    }
27
}
28