Completed
Push — master ( 6b8416...c520c0 )
by Filipe
02:12
created

RequestHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 5 1
1
<?php
2
3
/**
4
 * This file is part of slick/http
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Http\Server;
11
12
use Interop\Http\Server\RequestHandlerInterface;
13
use Psr\Http\Message\ResponseInterface;
14
use Psr\Http\Message\ServerRequestInterface;
15
16
/**
17
 * RequestHandler
18
 *
19
 * @package Slick\Http\Server
20
*/
21
class RequestHandler implements RequestHandlerInterface
22
{
23
    /**
24
     * @var callable
25
     */
26
    private $callback;
27
28
    /**
29
     * Creates a Request Handler
30
     *
31
     * @param callable $callback
32
     */
33
    public function __construct(callable $callback)
34
    {
35
        $this->callback = $callback;
36
    }
37
38
    /**
39
     * Handle the request and return a response.
40
     *
41
     * @param ServerRequestInterface $request
42
     *
43
     * @return ResponseInterface
44
     */
45
    public function handle(ServerRequestInterface $request)
46
    {
47
        $response = call_user_func($this->callback, $request);
48
        return $response;
49
    }
50
}