PassThroughRequestHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 19
ccs 0
cts 8
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 4 1
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
use function React\Promise\resolve;
13
14
/**
15
 * @internal
16
 */
17
final class PassThroughRequestHandler implements RequestHandlerInterface
18
{
19
    /**
20
     * @var callable
21
     */
22
    private $next;
23
24
    /**
25
     * @param callable $next
26
     */
27
    public function __construct(callable $next)
28
    {
29
        $this->next = $next;
30
    }
31
32
    public function handle(ServerRequestInterface $request): ResponseInterface
33
    {
34
        return new PromiseResponse(resolve($this->next)
35
            ->then(static fn($next) => $next($request)->current()));
36
    }
37
}
38