CallableHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of coisa/http.
5
 *
6
 * (c) Felipe Sayão Lobato Abreu <[email protected]>
7
 *
8
 * This source file is subject to the license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
declare(strict_types=1);
13
14
namespace CoiSA\Http\Handler;
15
16
use Psr\Http\Message\ResponseInterface;
17
use Psr\Http\Message\ServerRequestInterface;
18
use Psr\Http\Server\RequestHandlerInterface;
19
20
/**
21
 * Class CallableHandler
22
 *
23
 * @package CoiSA\Http\Handler
24
 */
25
class CallableHandler implements RequestHandlerInterface
26
{
27
    /**
28
     * @var callable
29
     */
30
    private $callback;
31
32
    /**
33
     * CallableHandler constructor.
34
     *
35
     * @param callable $callback
36
     */
37 2
    public function __construct(callable $callback)
38
    {
39 2
        $this->callback = $callback;
40 2
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 2
    public function handle(ServerRequestInterface $request): ResponseInterface
46
    {
47 2
        return \call_user_func($this->callback, $request);
48
    }
49
}
50