RouterDispatchHandler::main()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lit\Voltage;
6
7
use Lit\Nimo\Handlers\AbstractHandler;
8
use Lit\Voltage\Interfaces\RouterInterface;
9
use Psr\Http\Message\ResponseInterface;
10
11
/**
12
 * Handle request with embeded router
13
 */
14
class RouterDispatchHandler extends AbstractHandler
15
{
16
    /**
17
     * @var RouterInterface
18
     */
19
    protected $router;
20
21
    /**
22
     * @param RouterInterface $router Router instance to be used.
23
     */
24
    public function __construct(RouterInterface $router)
25
    {
26
        $this->router = $router;
27
    }
28
29
    /**
30
     * @return ResponseInterface
31
     */
32
    protected function main(): ResponseInterface
33
    {
34
        $action = $this->router->route($this->request);
35
36
        return $action->handle($this->request);
37
    }
38
}
39