MiddlewareRequestHandlerAdapter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\SlimPsr15;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Psr\Http\Server\RequestHandlerInterface;
10
11
final class MiddlewareRequestHandlerAdapter implements RequestHandlerInterface
12
{
13
    /**
14
     * @var ResponseInterface
15
     */
16
    private $response;
17
18
    /**
19
     * @var callable
20
     */
21
    private $next;
22
23 1
    public function __construct(ResponseInterface $response, callable $next)
24
    {
25 1
        $this->response = $response;
26 1
        $this->next = $next;
27 1
    }
28
29 1
    public function handle(ServerRequestInterface $request): ResponseInterface
30
    {
31 1
        $next = $this->next;
32
33 1
        return $next($request, $this->response);
34
    }
35
}
36