AppKernel   C
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 9.68 %

Coupling/Cohesion

Components 2
Dependencies 20

Importance

Changes 0
Metric Value
wmc 8
lcom 2
cbo 20
dl 6
loc 62
rs 6.4705
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getRootDir() 0 4 1
A getCacheDir() 0 4 1
A getLogDir() 0 4 1
A registerContainerConfiguration() 0 4 1
A getContainerBaseClass() 0 8 2
B registerBundles() 6 30 2

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 Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Kreta\TaskManager\Infrastructure\Symfony\Framework;
16
17
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
18
use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle;
19
use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle;
20
use Http\HttplugBundle\HttplugBundle;
21
use Kreta\TaskManager\Infrastructure\Symfony\Bundle\AppBundle;
22
use Nelmio\CorsBundle\NelmioCorsBundle;
23
use OldSound\RabbitMqBundle\OldSoundRabbitMqBundle;
24
use Overblog\GraphQLBundle\OverblogGraphQLBundle;
25
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
26
use Sensio\Bundle\DistributionBundle\SensioDistributionBundle;
27
use SimpleBus\SymfonyBridge\DoctrineOrmBridgeBundle;
28
use SimpleBus\SymfonyBridge\SimpleBusCommandBusBundle;
29
use SimpleBus\SymfonyBridge\SimpleBusEventBusBundle;
30
use Symfony\Bundle\DebugBundle\DebugBundle;
31
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
32
use Symfony\Bundle\MonologBundle\MonologBundle;
33
use Symfony\Bundle\SecurityBundle\SecurityBundle;
34
use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle;
35
use Symfony\Bundle\TwigBundle\TwigBundle;
36
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
37
use Symfony\Component\Config\Loader\LoaderInterface;
38
use Symfony\Component\HttpKernel\Kernel;
39
use Warezgibzzz\QueryBusBundle\WarezgibzzzQueryBusBundle;
40
41
class AppKernel extends Kernel
42
{
43
    public function registerBundles() : array
44
    {
45
        $bundles = [
46
            new AppBundle(),
47
            new DoctrineBundle(),
48
            new DoctrineMigrationsBundle(),
49
            new DoctrineOrmBridgeBundle(),
50
            new FrameworkBundle(),
51
            new HttplugBundle(),
52
            new MonologBundle(),
53
            new NelmioCorsBundle(),
54
            new OldSoundRabbitMqBundle(),
55
            new OverblogGraphQLBundle(),
56
            new SecurityBundle(),
57
            new SimpleBusCommandBusBundle(),
58
            new SimpleBusEventBusBundle(),
59
            new SwiftmailerBundle(),
60
            new TwigBundle(),
61
            new WarezgibzzzQueryBusBundle(),
62
        ];
63
64 View Code Duplication
        if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
65
            $bundles[] = new DebugBundle();
66
            $bundles[] = new DoctrineFixturesBundle();
67
            $bundles[] = new SensioDistributionBundle();
68
            $bundles[] = new WebProfilerBundle();
69
        }
70
71
        return $bundles;
72
    }
73
74
    public function getRootDir() : string
75
    {
76
        return __DIR__;
77
    }
78
79
    public function getCacheDir() : string
80
    {
81
        return dirname(__DIR__) . '/../../../../../var/cache/' . $this->getEnvironment();
82
    }
83
84
    public function getLogDir() : string
85
    {
86
        return dirname(__DIR__) . '/../../../../../var/logs';
87
    }
88
89
    public function registerContainerConfiguration(LoaderInterface $loader) : void
90
    {
91
        $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
92
    }
93
94
    protected function getContainerBaseClass() : string
95
    {
96
        if ('test' === $this->environment) {
97
            return MockerContainer::class;
98
        }
99
100
        return parent::getContainerBaseClass();
101
    }
102
}
103