ApplicationWrapper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace PHPFastCGI\Adapter\Silex;
4
5
use PHPFastCGI\FastCGIDaemon\Http\RequestInterface;
6
use PHPFastCGI\FastCGIDaemon\KernelInterface;
7
use Silex\Application;
8
9
/**
10
 * Wraps a Silex application object as an implementation of the kernel interface
11
 */
12
class ApplicationWrapper implements KernelInterface
13
{
14
    /**
15
     * @var Application
16
     */
17
    private $application;
18
19
    /**
20
     * Constructor.
21
     * 
22
     * @param Application $application The Silex application object to wrap
23
     */
24
    public function __construct(Application $application)
25
    {
26
        $this->application = $application;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function handleRequest(RequestInterface $request)
33
    {
34
        $symfonyRequest  = $request->getHttpFoundationRequest();
35
        $symfonyResponse = $this->application->handle($symfonyRequest);
36
37
        $this->application->terminate($symfonyRequest, $symfonyResponse);
38
39
        return $symfonyResponse;
40
    }
41
}
42