Passed
Push — master ( 049287...68f58a )
by Divine Niiquaye
03:27
created

CallbackHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Flight Routing.
7
 *
8
 * PHP version 7.4 and above required
9
 *
10
 * @author    Divine Niiquaye Ibok <[email protected]>
11
 * @copyright 2019 Biurad Group (https://biurad.com/)
12
 * @license   https://opensource.org/licenses/BSD-3-Clause License
13
 *
14
 * For the full copyright and license information, please view the LICENSE
15
 * file that was distributed with this source code.
16
 */
17
18
namespace Flight\Routing\Handlers;
19
20
use Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
21
use Psr\Http\Server\RequestHandlerInterface;
22
23
final class CallbackHandler implements RequestHandlerInterface
24
{
25
    /** @var callable */
26
    private $callback;
27
28 8
    public function __construct(callable $callback)
29
    {
30 8
        $this->callback = $callback;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 7
    public function handle(ServerRequestInterface $request): ResponseInterface
37
    {
38 7
        return ($this->callback)($request);
39
    }
40
}
41