PipeNextHandler::handle()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lit\Nimo\Handlers;
6
7
use Lit\Nimo\Middlewares\MiddlewarePipe;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use Psr\Http\Server\RequestHandlerInterface;
11
12
/**
13
 * State object as a RequestHandler, representing a "$next" handler.
14
 * Used with MiddlewarePipe.
15
 */
16
class PipeNextHandler implements RequestHandlerInterface
17
{
18
    /**
19
     * @var MiddlewarePipe
20
     */
21
    protected $pipe;
22
    /**
23
     * @var int
24
     */
25
    protected $index;
26
27
    /**
28
     * PipeNextHandler constructor.
29
     * @param MiddlewarePipe $pipe The MiddlewarePipe.
30
     * @param int $index Current iteration index.
31
     */
32 3
    public function __construct(MiddlewarePipe $pipe, int $index)
33
    {
34 3
        $this->pipe = $pipe;
35 3
        $this->index = $index;
36 3
    }
37
38 3
    public function handle(ServerRequestInterface $request): ResponseInterface
39
    {
40 3
        return $this->pipe->iterate($request, $this->index);
41
    }
42
}
43