Completed
Pull Request — master (#366)
by Beñat
14:40
created

AppKernel   B

Complexity

Total Complexity 9

Size/Duplication

Total Lines 62
Duplicated Lines 14.52 %

Coupling/Cohesion

Components 2
Dependencies 16

Importance

Changes 0
Metric Value
wmc 9
lcom 2
cbo 16
dl 9
loc 62
rs 8.4614
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
B registerBundles() 9 30 3
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

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\Notifier\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 Nelmio\CorsBundle\NelmioCorsBundle;
22
use OldSound\RabbitMqBundle\OldSoundRabbitMqBundle;
23
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
24
use SimpleBus\SymfonyBridge\SimpleBusCommandBusBundle;
25
use SimpleBus\SymfonyBridge\SimpleBusEventBusBundle;
26
use Snc\RedisBundle\SncRedisBundle;
27
use Symfony\Bundle\DebugBundle\DebugBundle;
28
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
29
use Symfony\Bundle\MonologBundle\MonologBundle;
30
use Symfony\Bundle\SecurityBundle\SecurityBundle;
31
use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle;
32
use Symfony\Bundle\TwigBundle\TwigBundle;
33
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
34
use Symfony\Bundle\WebServerBundle\WebServerBundle;
35
use Symfony\Component\Config\Loader\LoaderInterface;
36
use Symfony\Component\HttpKernel\Kernel;
37
38
class AppKernel extends Kernel
39
{
40
    public function registerBundles() : array
41
    {
42
        $bundles = [
43
            new DoctrineBundle(),
44
            new DoctrineMigrationsBundle(),
45
            new FrameworkBundle(),
46
            new HttplugBundle(),
47
            new MonologBundle(),
48
            new NelmioCorsBundle(),
49
            new OldSoundRabbitMqBundle(),
50
            new SecurityBundle(),
51
            new SimpleBusCommandBusBundle(),
52
            new SimpleBusEventBusBundle(),
53
            new SncRedisBundle(),
54
            new SwiftmailerBundle(),
55
            new TwigBundle(),
56
        ];
57
58 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...
59
            $bundles[] = new DebugBundle();
60
            $bundles[] = new WebProfilerBundle();
61
62
            if ('dev' === $this->getEnvironment()) {
63
                $bundles[] = new DoctrineFixturesBundle();
64
                $bundles[] = new WebServerBundle();
65
            }
66
        }
67
68
        return $bundles;
69
    }
70
71
    public function getRootDir() : string
72
    {
73
        return __DIR__;
74
    }
75
76
    public function getCacheDir() : string
77
    {
78
        return dirname(__DIR__) . '/../../../../../var/cache/' . $this->getEnvironment();
79
    }
80
81
    public function getLogDir() : string
82
    {
83
        return dirname(__DIR__) . '/../../../../../var/logs';
84
    }
85
86
    public function registerContainerConfiguration(LoaderInterface $loader) : void
87
    {
88
        $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
89
    }
90
91
    protected function getContainerBaseClass() : string
92
    {
93
        if ('test' === $this->environment) {
94
            return MockerContainer::class;
95
        }
96
97
        return parent::getContainerBaseClass();
98
    }
99
}
100