AppKernel::getExtensions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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