Completed
Push — master ( 636ba4...2157e7 )
by Jean-Bernard
05:46 queued 03:53
created

ComponentKernel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 7
dl 37
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A registerBundles() 7 7 1
A configureRoutes() 4 4 1
A configureContainer() 19 19 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Bundle\FrameworkBundle\FrameworkBundle;
13
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
14
use Symfony\Bundle\TwigBundle\TwigBundle;
15
use Symfony\Component\Config\Loader\LoaderInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\HttpKernel\Kernel;
18
use Symfony\Component\Routing\RouteCollectionBuilder;
19
20 View Code Duplication
class ComponentKernel 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...
21
{
22
    use MicroKernelTrait;
23
24
    public function registerBundles()
25
    {
26
        return [
27
            new FrameworkBundle(),
28
            new TwigBundle(),
29
        ];
30
    }
31
32
    protected function configureRoutes(RouteCollectionBuilder $routes)
33
    {
34
        $routes->add('/', SymfonyUtil\Controller\EngineAsArgumentController::class, 'index');
35
    }
36
37
    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...
38
    {
39
        //Controllers
40
        $c->autowire(SymfonyUtil\Controller\EngineAsArgumentController::class)
41
            ->setAutoconfigured(true)
42
            ->addTag('controller.service_arguments')
43
            ->setPublic(false);
44
45
        // Extensions
46
        $c->loadFromExtension('framework', [
47
            'secret' => 'NotSecret', // What about use $ uuid -v4  or $ uuidgen
48
            'test' => in_array($this->getEnvironment(), ['test'], true), // test.client service for eg. PHPUnit
49
            'templating' => ['engines' => 'twig'],
50
        ]);
51
        $c->loadFromExtension('twig', [
52
            'debug' => true,
53
            'paths' => ['%kernel.project_dir%/tests/templates'],
54
        ]);
55
    }
56
}
57