Passed
Push — main ( a1a461...2097df )
by Thomas
12:50
created

MiddlewareWrapper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Conia\Chuck\Http;
6
7
use Closure;
8
use Conia\Chuck\Middleware;
9
use Conia\Chuck\Request;
10
use Conia\Chuck\Response;
11
12
class MiddlewareWrapper implements Middleware
13
{
14
    protected Closure $callable;
15
16
    /** @psalm-param callable(Request, callable):Response $callable */
17 4
    public function __construct(callable $callable)
18
    {
19 4
        $this->callable = Closure::fromCallable($callable);
20
    }
21
22 4
    public function __invoke(
23
        Request $request,
24
        callable $next
25
    ): Response {
26
        /** @psalm-var Closure(Request, callable):Response $this->callable */
27 4
        return ($this->callable)($request, $next);
28
    }
29
}
30