Passed
Push — master ( 74361b...e1642a )
by Anatoly
04:30 queued 01:45
created

CallableMiddleware   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A process() 0 3 1
1
<?php declare(strict_types=1);
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Fenric <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Fenric
8
 * @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-router
10
 */
11
12
namespace Sunrise\Http\Router\Middleware;
13
14
/**
15
 * Import classes
16
 */
17
use Psr\Http\Message\ResponseInterface;
18
use Psr\Http\Message\ServerRequestInterface;
19
use Psr\Http\Server\MiddlewareInterface;
20
use Psr\Http\Server\RequestHandlerInterface;
21
22
/**
23
 * CallableMiddleware
24
 *
25
 * @since 2.8.0
26
 */
27
class CallableMiddleware implements MiddlewareInterface
28
{
29
30
    /**
31
     * The middleware callback
32
     *
33
     * @var callable
34
     */
35
    private $callback;
36
37
    /**
38
     * Constructor of the class
39
     *
40
     * @param callable $callback
41
     */
42 4
    public function __construct(callable $callback)
43
    {
44 4
        $this->callback = $callback;
45 4
    }
46
47
    /**
48
     * {@inheritDoc}
49
     */
50 3
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
51
    {
52 3
        return ($this->callback)($request, $handler);
53
    }
54
}
55