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

MiddlewareWrapper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 4
dl 0
loc 16
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 6 1
A __construct() 0 3 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