CallbackHandler   A
last analyzed

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