AppKernel   C
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 81
Duplicated Lines 7.41 %

Coupling/Cohesion

Components 1
Dependencies 37

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 37
dl 6
loc 81
rs 5
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A registerBundles() 6 47 2
A getRootDir() 0 4 1
A getCacheDir() 0 4 1
A getLogDir() 0 4 1
A registerContainerConfiguration() 0 4 1
A buildContainer() 0 10 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 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\IdentityAccess\Infrastructure\Symfony\Framework;
16
17
use BenGorFile\DoctrineORMBridgeBundle\BenGorFileDoctrineORMBridgeBundle;
18
use BenGorFile\FileBundle\BenGorFileBundle;
19
use BenGorFile\GaufretteFilesystemBridgeBundle\BenGorFileGaufretteFilesystemBridgeBundle;
20
use BenGorFile\SimpleBusBridgeBundle\BenGorFileSimpleBusBridgeBundle;
21
use BenGorFile\SimpleBusBridgeBundle\BenGorFileSimpleBusDoctrineORMBridgeBundle;
22
use BenGorUser\UserBundle\BenGorUserBundle;
23
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
24
use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle;
25
use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle;
26
use Knp\Bundle\GaufretteBundle\KnpGaufretteBundle;
27
use Kreta\IdentityAccess\Infrastructure\Symfony\DependencyInjection\Compiler\OverrideUserDataTransformerServicePass;
28
use Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle;
29
use Nelmio\CorsBundle\NelmioCorsBundle;
30
use OldSound\RabbitMqBundle\OldSoundRabbitMqBundle;
31
use Sensio\Bundle\DistributionBundle\SensioDistributionBundle;
32
use SimpleBus\AsynchronousBundle\SimpleBusAsynchronousBundle;
33
use SimpleBus\RabbitMQBundleBridge\SimpleBusRabbitMQBundleBridgeBundle;
34
use SimpleBus\SymfonyBridge\DoctrineOrmBridgeBundle;
35
use SimpleBus\SymfonyBridge\SimpleBusCommandBusBundle;
36
use SimpleBus\SymfonyBridge\SimpleBusEventBusBundle;
37
use Symfony\Bundle\DebugBundle\DebugBundle;
38
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
39
use Symfony\Bundle\MonologBundle\MonologBundle;
40
use Symfony\Bundle\SecurityBundle\SecurityBundle;
41
use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle;
42
use Symfony\Bundle\TwigBundle\TwigBundle;
43
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
44
use Symfony\Component\Config\Loader\LoaderInterface;
45
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
46
use Symfony\Component\HttpKernel\Kernel;
47
use Warezgibzzz\QueryBusBundle\WarezgibzzzQueryBusBundle;
48
49
class AppKernel extends Kernel
50
{
51
    public function registerBundles() : array
52
    {
53
        $bundles = [
54
            new DoctrineBundle(),
55
            new DoctrineMigrationsBundle(),
56
            new DoctrineOrmBridgeBundle(),
57
            new FrameworkBundle(),
58
            new LexikJWTAuthenticationBundle(),
59
            new MonologBundle(),
60
            new NelmioCorsBundle(),
61
            new SecurityBundle(),
62
            new SimpleBusCommandBusBundle(),
63
            new SimpleBusEventBusBundle(),
64
            new SwiftmailerBundle(),
65
            new TwigBundle(),
66
67
            new SimpleBusAsynchronousBundle(),
68
            new SimpleBusRabbitMQBundleBridgeBundle(),
69
            new OldSoundRabbitMqBundle(),
70
            new WarezgibzzzQueryBusBundle(),
71
72
            new KnpGaufretteBundle(),
73
            new BenGorFileGaufretteFilesystemBridgeBundle(),
74
            new BenGorFileDoctrineORMBridgeBundle(),
75
            new BenGorFileSimpleBusBridgeBundle(),
76
            new BenGorFileSimpleBusDoctrineORMBridgeBundle(),
77
            new BenGorFileBundle(),
78
79
            new \BenGorUser\TwigBridgeBundle\TwigBridgeBundle(),
80
            new \BenGorUser\SymfonyRoutingBridgeBundle\SymfonyRoutingBridgeBundle(),
81
            new \BenGorUser\SymfonySecurityBridgeBundle\SymfonySecurityBridgeBundle(),
82
            new \BenGorUser\SwiftMailerBridgeBundle\SwiftMailerBridgeBundle(),
83
            new \BenGorUser\DoctrineORMBridgeBundle\DoctrineORMBridgeBundle(),
84
            new \BenGorUser\SimpleBusBridgeBundle\SimpleBusBridgeBundle(),
85
            new \BenGorUser\SimpleBusBridgeBundle\SimpleBusDoctrineORMBridgeBundle(),
86
            new BenGorUserBundle(),
87
        ];
88
89 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...
90
            $bundles[] = new DebugBundle();
91
            $bundles[] = new DoctrineFixturesBundle();
92
            $bundles[] = new SensioDistributionBundle();
93
            $bundles[] = new WebProfilerBundle();
94
        }
95
96
        return $bundles;
97
    }
98
99
    public function getRootDir() : string
100
    {
101
        return __DIR__;
102
    }
103
104
    public function getCacheDir() : string
105
    {
106
        return dirname(__DIR__) . '/../../../../../var/cache/' . $this->getEnvironment();
107
    }
108
109
    public function getLogDir() : string
110
    {
111
        return dirname(__DIR__) . '/../../../../../var/logs';
112
    }
113
114
    public function registerContainerConfiguration(LoaderInterface $loader) : void
115
    {
116
        $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
117
    }
118
119
    protected function buildContainer()
120
    {
121
        $container = parent::buildContainer();
122
        $container->addCompilerPass(
123
            new OverrideUserDataTransformerServicePass($this),
124
            PassConfig::TYPE_OPTIMIZE
125
        );
126
127
        return $container;
128
    }
129
}
130