Test Failed
Push — master ( 580b23...e2e68e )
by Jean-Bernard
02:01
created

AppKernel::configureRoutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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\Component;
13
14
use Symfony\Bridge\Twig\TwigEngine;
15
use Symfony\Bundle\FrameworkBundle\Client;
16
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
17
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
18
use Symfony\Component\Config\Loader\LoaderInterface;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\HttpKernel\Kernel;
21
use Symfony\Component\Routing\RouteCollectionBuilder;
22
use Symfony\Component\Templating\EngineInterface;
23
use Symfony\Component\Templating\TemplateNameParser;
24
use Symfony\Component\Templating\TemplateNameParserInterface;
25
use SymfonyUtil\Controller\EngineAsArgumentController;
26
27
// use Twig_Environment;
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% 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...
28
// use Twig_Loader_Array;
29
30 View Code Duplication
class AppKernel extends Kernel
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
{
32
    use MicroKernelTrait;
33
34
    public function registerBundles()
35
    {
36
        return [
37
            new FrameworkBundle(),
38
        ];
39
    }
40
41
    protected function configureRoutes(RouteCollectionBuilder $routes)
42
    {
43
        $routes->add('/', EngineAsArgumentController::class, 'index');
44
    }
45
46
    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...
47
    {
48
        // https://symfony.com/doc/current/service_container.html
49
        $c->autowire(TemplateNameParser::class)
50
            ->setAutoconfigured(true)
51
            ->setPublic(false);
52
        $c->setAlias(TemplateNameParserInterface::class, TemplateNameParser::class);
53
54
        $c->autowire(Twig_Loader_Array::class, Twig_Loader_Array::class)
55
            ->setArgument('$templates', ['index.html.twig' => 'Hello Component!'])
56
            ->setAutoconfigured(true)
57
            ->setPublic(false);
58
        $c->setAlias(Twig_LoaderInterface::class, Twig_Loader_Array::class);
59
60
        $c->autowire(Twig_Environment::class, Twig_Environment::class)
61
            ->setAutoconfigured(true)
62
            ->setPublic(false);
63
        $c->setAlias(Twig\Environment::class, Twig_Environment::class);
64
65
        $c->autowire(TwigEngine::class)
66
            ->setAutoconfigured(true)
67
            ->setPublic(false);
68
        $c->setAlias(EngineInterface::class, TwigEngine::class);
69
70
        if (in_array($this->getEnvironment(), ['test'], true)) {
71
            $c->autowire('test.client', Client::class)
72
                ->setPublic(true); // Public needed!
73
        }
74
75
        //Controllers
76
        $c->autowire(EngineAsArgumentController::class)
77
            ->setAutoconfigured(true)
78
            ->addTag('controller.service_arguments')
79
            ->setPublic(false);
80
81
        // Extensions
82
        $c->loadFromExtension('framework', [
83
            'secret' => 'NotSecret', // What about use $ uuid -v4  or $ uuidgen
84
        ]);
85
    }
86
}
87
88
// Information for Service "test.client"
89
// =====================================
90
91
//  ---------------- ---------------------------------------
92
//   Option           Value
93
//  ---------------- ---------------------------------------
94
//   Service ID       test.client
95
//   Class            Symfony\Bundle\FrameworkBundle\Client
96
//   Tags             -
97
//   Public           yes
98
//   Synthetic        no
99
//   Lazy             no
100
//   Shared           no
101
//   Abstract         no
102
//   Autowired        no
103
//   Autoconfigured   no
104
//  ---------------- ---------------------------------------
105