Test Failed
Push — master ( 0d3907...f5ae4e )
by Jean-Bernard
02:12
created

AppKernel::configureContainer()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 40
Code Lines 12

Duplication

Lines 40
Ratio 100 %

Importance

Changes 0
Metric Value
dl 40
loc 40
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 2
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
use Symfony\Bridge\Twig\TwigEngine;
13
use Symfony\Bundle\FrameworkBundle\Client;
14
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
15
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
16
use Symfony\Component\Config\Loader\LoaderInterface;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\HttpKernel\Kernel;
19
use Symfony\Component\Routing\RouteCollectionBuilder;
20
use Symfony\Component\Templating\EngineInterface;
21
use Symfony\Component\Templating\TemplateNameParser;
22
use Symfony\Component\Templating\TemplateNameParserInterface;
23
use SymfonyUtil\Controller\EngineAsArgumentController;
24
25
// 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...
26
// use Twig_Loader_Array;
27
28 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...
29
{
30
    use MicroKernelTrait;
31
32
    public function registerBundles()
33
    {
34
        return [
35
            new FrameworkBundle(),
36
        ];
37
    }
38
39
    protected function configureRoutes(RouteCollectionBuilder $routes)
40
    {
41
        $routes->add('/', EngineAsArgumentController::class, 'index');
42
    }
43
44
    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...
45
    {
46
        // https://symfony.com/doc/current/service_container.html
47
        $c->autowire(TemplateNameParser::class)
48
            ->setAutoconfigured(true)
49
            ->setPublic(false);
50
        $c->setAlias(TemplateNameParserInterface::class, TemplateNameParser::class);
51
52
        $c->autowire(Twig_Loader_Array::class, Twig_Loader_Array::class)
53
            ->setArgument('$templates', ['index.html.twig' => 'Hello Component!'])
54
            ->setAutoconfigured(true)
55
            ->setPublic(false);
56
        $c->setAlias(Twig_LoaderInterface::class, Twig_Loader_Array::class);
57
58
        $c->autowire(Twig_Environment::class, Twig_Environment::class)
59
            ->setAutoconfigured(true)
60
            ->setPublic(false);
61
        $c->setAlias(Twig\Environment::class, Twig_Environment::class);
62
63
        $c->autowire(TwigEngine::class)
64
            ->setAutoconfigured(true)
65
            ->setPublic(false);
66
        $c->setAlias(EngineInterface::class, TwigEngine::class);
67
68
        if (in_array($this->getEnvironment(), ['test'], true)) {
69
            $c->autowire('test.client', Client::class)
70
                ->setPublic(true); // Public needed!
71
        }
72
73
        //Controllers
74
        $c->autowire(EngineAsArgumentController::class)
75
            ->setAutoconfigured(true)
76
            ->addTag('controller.service_arguments')
77
            ->setPublic(false);
78
79
        // Extensions
80
        $c->loadFromExtension('framework', [
81
            'secret' => 'NotSecret', // What about use $ uuid -v4  or $ uuidgen
82
        ]);
83
    }
84
}
85
86
// Information for Service "test.client"
87
// =====================================
88
89
//  ---------------- ---------------------------------------
90
//   Option           Value
91
//  ---------------- ---------------------------------------
92
//   Service ID       test.client
93
//   Class            Symfony\Bundle\FrameworkBundle\Client
94
//   Tags             -
95
//   Public           yes
96
//   Synthetic        no
97
//   Lazy             no
98
//   Shared           no
99
//   Abstract         no
100
//   Autowired        no
101
//   Autoconfigured   no
102
//  ---------------- ---------------------------------------
103