Completed
Push — master ( 028a2f...d99482 )
by Andrew
02:00
created

AppWrapper::finalizeResponse()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 16
rs 9.2
cc 4
eloc 9
nc 3
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