Test Failed
Push — master ( 2f92a1...abdbcd )
by Jean-Bernard
02:23
created

AppKernel::configureRoutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Symfony-Util package.
5
 *
6
 * (c) Jean-Bernard Addor
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
// namespace Tests\FrameworkTwig;
13
14
use Knp\Rad\ResourceResolver\Bundle\ResourceResolverBundle;
15
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
16
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
17
use Symfony\Bundle\TwigBundle\TwigBundle;
18
use Symfony\Bundle\WebServerBundle\WebServerBundle;
19
use Symfony\Component\Config\Loader\LoaderInterface;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
use Symfony\Component\HttpKernel\Kernel;
22
use Symfony\Component\Routing\Route;
23
use Symfony\Component\Routing\RouteCollectionBuilder;
24
use SymfonyUtil\Controller\EngineAsArgumentController;
25
use SymfonyUtil\Controller\TemplatingController;
26
use SymfonyUtil\Controller\VariadicController;
27
use Tests\FrameworkTwig\Identity;
28
29
class AppKernel extends Kernel
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type AppKernel has been defined more than once; this definition is ignored, only the first definition in tests/Framework/src/AppKernel.php (L29-92) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
30
{
31
    use MicroKernelTrait;
32
33
    public function registerBundles()
34
    {
35
        return [
36
            new FrameworkBundle(),
37
            new ResourceResolverBundle(),
38
            new TwigBundle(),
39
            new WebServerBundle(),
40
        ];
41
    }
42
43
    protected function configureRoutes(RouteCollectionBuilder $routes)
44
    {
45
        $routes->add('/', EngineAsArgumentController::class, 'index');
46
        $routes->add('/argument', EngineAsArgumentController::class, 'argument');
47
        $routes->add('/constructor', TemplatingController::class, 'constructor');
48
        $routes->addRoute(new Route('/variadic/request', [
49
                '_controller' => VariadicController::class,
50
                '_resources' => [Identity::class, ['$request']],
51
            ]),
52
            'variadic_request'
53
        );
54
    }
55
56
    protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
0 ignored issues
show
Unused Code introduced by
The parameter $loader is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
57
    {
58
        //Controllers
59
        $c->autowire(EngineAsArgumentController::class)
60
            ->setAutoconfigured(true)
61
            ->addTag('controller.service_arguments')
62
            ->setPublic(true);
63
64
        $c->autowire(TemplatingController::class)
65
            ->setAutoconfigured(true)
66
            // ->addTag('controller.service_arguments')
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
67
            ->setPublic(true);
68
69
        $c->autowire(VariadicController::class)
70
            ->setAutoconfigured(true)
71
            ->setPublic(true);
72
73
        $c->autowire(Identity::class)
74
            ->setAutoconfigured(true)
75
            ->setPublic(true);
76
77
        // Extensions
78
        $c->loadFromExtension('framework', [
79
            'secret' => 'NotSecret', // What about use $ uuid -v4  or $ uuidgen
80
            'test' => in_array($this->getEnvironment(), ['test'], true), // test.client service for eg. PHPUnit
81
            'templating' => ['engines' => 'twig'],
82
        ]);
83
        $c->loadFromExtension('twig', [
84
            'debug' => true,
85
            'paths' => ['%kernel.project_dir%/tests/templates'],
86
        ]);
87
    }
88
}
89