Completed
Push — master ( 1b3a7e...f4d44d )
by Pavel
04:33
created

CrudsExtension::load()   B

Complexity

Conditions 5
Paths 9

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 5.0061

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 15
cts 16
cp 0.9375
rs 8.6737
c 0
b 0
f 0
cc 5
eloc 13
nc 9
nop 2
crap 5.0061
1
<?php
2
3
namespace ScayTrase\Api\Cruds\DependencyInjection;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Extension\Extension;
8
use Symfony\Component\DependencyInjection\Loader;
9
10
final class CrudsExtension extends Extension
11
{
12
    /** {@inheritdoc} */
13 2
    public function load(array $configs, ContainerBuilder $container)
14
    {
15 2
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
16 2
        $loader->load('cruds.yml');
17
18 2
        $config = $this->processConfiguration($this->getConfiguration([], $container), $configs);
0 ignored issues
show
Documentation introduced by
$this->getConfiguration(array(), $container) is of type object|null, 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...
19
20 2
        $configurator = new CrudsEntitiesConfigurator($container);
21 2
        $container->addObjectResource($configurator);
22 2
        foreach ($config['entities'] as $name => $entityConfig) {
23 2
            $entityConfig['prefix'] = $entityConfig['prefix'] ?: '/' . $name;
24 2
            $configurator->processEntityConfiguration($name, $entityConfig);
25 2
        }
26
27 2
        foreach ($config['listeners'] as $listener => $enabled) {
28 2
            if ($enabled) {
29 2
                continue;
30
            }
31
32
            $container->removeDefinition('cruds.api.listener.' . $listener);
33 2
        }
34 2
    }
35
}
36