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

CallbackHandler::__construct()   A

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
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