DunglasDoctrineJsonOdmExtension::prepend()   A
last analyzed

Complexity

Conditions 6
Paths 5

Size

Total Lines 14

Duplication

Lines 6
Ratio 42.86 %

Importance

Changes 0
Metric Value
cc 6
nc 5
nop 1
dl 6
loc 14
rs 9.2222
c 0
b 0
f 0
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