AppKernel   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 22
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 1
A getExtensions() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application;
6
7
use Gnutix\Kernel\TwigAwareKernel;
8
use Gnutix\StarWarsLibrary\DependencyInjection\Extension as StarWarsLibraryExtension;
9
use Symfony\Component\HttpFoundation\Request;
10
use Symfony\Component\HttpFoundation\Response;
11
use Twig\Environment;
12
use Webmozart\Assert\Assert;
13
14
final class AppKernel extends TwigAwareKernel
15
{
16
    public function handle(Request $request, int $type = self::MASTER_REQUEST, bool $catch = true): Response
17
    {
18
        /** @var Environment $twig */
19
        $twig = $this->getContainer()->get('twig');
20
        Assert::isInstanceOf($twig, Environment::class);
21
22
        return new Response(
23
            $twig->render(
24
                'index.html.twig',
25
                [
26
                    'request' => $request,
27
                    'showLanguages' => $request->query->get('show-languages'),
28
                ]
29
            )
30
        );
31
    }
32
33
    protected function getExtensions(): array
34
    {
35
        return array_merge(parent::getExtensions(), [new StarWarsLibraryExtension()]);
36
    }
37
}
38