ActionDispatcherMiddleware   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 34
ccs 0
cts 7
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDispatcher() 0 3 1
A process() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace Nip\Dispatcher;
4
5
use Nip\Http\ServerMiddleware\Middlewares\ServerMiddlewareInterface;
6
use Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Message\ServerRequestInterface;
8
use Psr\Http\Server\RequestHandlerInterface;
9
10
/**
11
 * Class ActionDispatcherMiddleware
12
 * @package Nip\Dispatcher
13
 */
14
class ActionDispatcherMiddleware implements ServerMiddlewareInterface
15
{
16
    /**
17
     * The session manager.
18
     *
19
     * @var Dispatcher
20
     */
21
    protected $dispatcher;
22
23
    /**
24
     * Create a new session middleware.
25
     *
26
     * @param  Dispatcher $dispatcher
27
     */
28
    public function __construct(Dispatcher $dispatcher)
29
    {
30
        $this->dispatcher = $dispatcher;
31
    }
32
33
    /**
34
     * @inheritdoc
35
     * @throws \Exception
36
     */
37
    public function process(ServerRequestInterface $request, RequestHandlerInterface $delegate): ResponseInterface
38
    {
39
        return $this->getDispatcher()->dispatch($request);
40
    }
41
42
    /**
43
     * @return Dispatcher
44
     */
45
    protected function getDispatcher(): Dispatcher
46
    {
47
        return $this->dispatcher;
48
    }
49
}
50