DunglasDoctrineJsonOdmExtension   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 29
Duplicated Lines 20.69 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 4
dl 6
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A prepend() 6 14 6
A load() 0 5 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
 * (c) Kévin Dunglas <[email protected]>
5
 *
6
 * This source file is subject to the MIT license that is bundled
7
 * with this source code in the file LICENSE.
8
 */
9
10
namespace Dunglas\DoctrineJsonOdm\Bundle\DependencyInjection;
11
12
use Symfony\Component\Config\FileLocator;
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
15
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
16
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
17
18
/**
19
 * @author Kévin Dunglas <[email protected]>
20
 */
21
final class DunglasDoctrineJsonOdmExtension extends Extension implements PrependExtensionInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function prepend(ContainerBuilder $container)
27
    {
28
        if (empty($frameworkConfiguration = $container->getExtensionConfig('framework'))) {
29
            return;
30
        }
31
32 View Code Duplication
        if (!isset($frameworkConfiguration['serializer']) || !isset($frameworkConfiguration['serializer']['enabled'])) {
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...
33
            $container->prependExtensionConfig('framework', ['serializer' => ['enabled' => true]]);
34
        }
35
36 View Code Duplication
        if (!isset($frameworkConfiguration['property_info']) || !isset($frameworkConfiguration['property_info']['enabled'])) {
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...
37
            $container->prependExtensionConfig('framework', ['property_info' => ['enabled' => true]]);
38
        }
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function load(array $configs, ContainerBuilder $container)
45
    {
46
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
47
        $loader->load('services.xml');
48
    }
49
}
50