Completed
Push — master ( 5e5884...e3397a )
by Maxime
13s queued 11s
created

ElaoEnumExtension::getNamespace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the "elao/enum" package.
5
 *
6
 * Copyright (C) Elao
7
 *
8
 * @author Elao <[email protected]>
9
 */
10
11
namespace Elao\Enum\Bridge\Symfony\Bundle\DependencyInjection;
12
13
use Elao\Enum\Bridge\Symfony\HttpKernel\Controller\ArgumentResolver\EnumValueResolver;
14
use Elao\Enum\Bridge\Symfony\Serializer\Normalizer\EnumNormalizer;
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
18
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
19
20
class ElaoEnumExtension extends Extension
21
{
22
    public function load(array $configs, ContainerBuilder $container)
23
    {
24
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
25
        $loader->load('services.xml');
26
27
        $config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs);
0 ignored issues
show
Documentation introduced by
$this->getConfiguration($configs, $container) is of type null|object, but the function expects a object<Symfony\Component...ConfigurationInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
28
29
        if (!$this->isConfigEnabled($container, $config['argument_value_resolver'])) {
30
            $container->removeDefinition(EnumValueResolver::class);
31
        }
32
33
        if (!$this->isConfigEnabled($container, $config['serializer'])) {
34
            $container->removeDefinition(EnumNormalizer::class);
35
        }
36
    }
37
38
    public function getNamespace()
39
    {
40
        return 'http://elao.com/schema/dic/elao_enum';
41
    }
42
43
    public function getXsdValidationBasePath()
44
    {
45
        return __DIR__ . '/../Resources/config/schema';
46
    }
47
}
48