CallbackHandler::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
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