Completed
Push — master ( 055d6a...965bca )
by Beñat
12:39 queued 09:48
created

SimpleBusDoctrineODMMongoDBBridgeExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 6
dl 38
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 6 6 1
A prepend() 8 8 1
A addMiddlewareTags() 10 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 BenGorUser 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
namespace BenGorUser\SimpleBusBridgeBundle\DependencyInjection;
14
15
use BenGorUser\UserBundle\DependencyInjection\Configuration;
16
use Symfony\Component\Config\FileLocator;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
19
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
20
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
21
22
/**
23
 * Simple bus and Doctrine ODM MongoDB bridge bundle extension class.
24
 *
25
 * @author Beñat Espiña <[email protected]>
26
 */
27 View Code Duplication
class SimpleBusDoctrineODMMongoDBBridgeExtension extends Extension implements PrependExtensionInterface, SimpleBusTaggerExtension
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...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 129 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function load(array $configs, ContainerBuilder $container)
33
    {
34
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
35
36
        $loader->load('doctrine_odm_mongodb.yml');
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function prepend(ContainerBuilder $container)
43
    {
44
        $configuration = new Configuration();
45
        $configs = $container->getExtensionConfig('ben_gor_user');
46
        $config = $this->processConfiguration($configuration, $configs);
47
48
        $container->setParameter('bengor_user.config', $config);
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function addMiddlewareTags(ContainerBuilder $container, $user)
55
    {
56
        $container->getDefinition(
57
            'bengor_user.simple_bus_bridge_bundle.doctrine_odm_mongodb_transactional_middleware'
58
        )->addTag(
59
            'bengor_user_' . $user . '_command_bus_middleware', ['priority' => '0']
60
        );
61
62
        return $container;
63
    }
64
}
65