AppWrapper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handleRequest() 0 10 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