AppWrapper::handleRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4286
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
3
namespace PHPFastCGI\Adapter\Slim;
4
5
use PHPFastCGI\FastCGIDaemon\Http\RequestInterface;
6
use PHPFastCGI\FastCGIDaemon\KernelInterface;
7
use Slim\App;
8
use Slim\Http\Headers;
9
use Slim\Http\Response;
10
11
/**
12
 * Wraps a Slim v3 application object as an implementation of the kernel
13
 * interface.
14
 */
15
class AppWrapper implements KernelInterface
16
{
17
    /**
18
     * @var App
19
     */
20
    private $app;
21
22
    /**
23
     * Constructor.
24
     * 
25
     * @param App $app The Slim v3 application object to wrap
26
     */
27
    public function __construct(App $app)
28
    {
29
        $this->app = $app;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function handleRequest(RequestInterface $request)
36
    {
37
        $serverRequest = $request->getServerRequest();
38
39
        $headers = new Headers(['Content-Type' => 'text/html; charset=UTF-8']);
40
        $response = new Response(200, $headers);
41
        $response = $response->withProtocolVersion('1.1');
42
43
        return $this->app->process($serverRequest, $response);
44
    }
45
}
46