GoAopBundle   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 43.24 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 1
cbo 6
dl 16
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 11 2
A boot() 16 16 4

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
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2015, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Go\Symfony\GoAopBundle;
12
13
14
use Go\Instrument\ClassLoading\AopComposerLoader;
15
use Go\Symfony\GoAopBundle\DependencyInjection\Compiler\AspectCollectorPass;
16
use Symfony\Component\Debug\DebugClassLoader;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\HttpKernel\Bundle\Bundle;
19
20
class GoAopBundle extends Bundle
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function build(ContainerBuilder $container)
26
    {
27
        $bundles     = $container->getParameter('kernel.bundles');
28
        $firstBundle = key($bundles);
29
        if ($firstBundle !== $this->name) {
30
            $message = "Please move the {$this->name} initialization to the top in your Kernel->init()";
31
            throw new \InvalidArgumentException($message);
32
        }
33
34
        $container->addCompilerPass(new AspectCollectorPass());
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 View Code Duplication
    public function boot()
0 ignored issues
show
Duplication introduced by
This method 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...
41
    {
42
        // it is a quick way to check if loader was enabled
43
        $wasDebugEnabled = class_exists(DebugClassLoader::class, false);
44
        if ($wasDebugEnabled) {
45
            // disable temporary to apply AOP loader first
46
            DebugClassLoader::disable();
47
        }
48
        $this->container->get('goaop.aspect.container');
49
        if (!AopComposerLoader::wasInitialized()) {
50
            throw new \RuntimeException("Initialization of AOP loader was failed, probably due to Debug::enable()");
51
        }
52
        if ($wasDebugEnabled) {
53
            DebugClassLoader::enable();
54
        }
55
    }
56
}
57