Completed
Push — master ( be05e4...11542d )
by Taosikai
13:50
created

Delegate::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/*
3
 * This file is part of the slince/middleware package.
4
 *
5
 * (c) Slince <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Slince\Middleware;
12
13
use Interop\Http\Server\RequestHandlerInterface;
14
use Psr\Http\Message\ResponseInterface;
15
use Psr\Http\Message\ServerRequestInterface;
16
17
class Delegate implements RequestHandlerInterface
18
{
19
    /**
20
     * @var callable
21
     */
22
    protected $callback;
23
24
    public function __construct(callable $callback)
25
    {
26
        $this->callback = $callback;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function handle(ServerRequestInterface $request): ResponseInterface
33
    {
34
        return call_user_func($this->callback, $request);
35
    }
36
}