Passed
Push — master ( 465b21...de1506 )
by Koldo
05:36
created

PassThroughRequestHandler::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
ccs 0
cts 6
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Antidot\React;
6
7
use Generator;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use Psr\Http\Server\RequestHandlerInterface;
11
12
/**
13
 * @internal
14
 */
15
final class PassThroughRequestHandler implements RequestHandlerInterface
16
{
17
    /**
18
     * @var callable
19
     */
20
    private $next;
21
22
    /**
23
     * @param callable $next
24
     */
25
    public function __construct(callable $next)
26
    {
27
        $this->next = $next;
28
    }
29
30
    public function handle(ServerRequestInterface $request): ResponseInterface
31
    {
32
        $next = $this->next;
33
        /** @var Generator $handlerGenerator */
34
        $handlerGenerator = $next($request);
35
        $next = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $next is dead and can be removed.
Loading history...
36
37
        return new PromiseResponse($handlerGenerator->current());
38
    }
39
}
40