Completed
Pull Request — master (#22)
by Bernhard
19:02
created

PuliExtension::load()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 5.0074

Importance

Changes 6
Bugs 1 Features 2
Metric Value
c 6
b 1
f 2
dl 0
loc 24
ccs 14
cts 15
cp 0.9333
rs 8.5126
cc 5
eloc 15
nc 4
nop 2
crap 5.0074
1
<?php
2
3
/*
4
 * This file is part of the puli/symfony-bundle package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\SymfonyBundle\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Loader;
17
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
18
19
/**
20
 * @since  1.0
21
 *
22
 * @author Bernhard Schussek <[email protected]>
23
 */
24
class PuliExtension extends Extension
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29 3
    public function load(array $configs, ContainerBuilder $container)
30
    {
31 3
        $bundles = $container->getParameter('kernel.bundles');
32
33 3
        $configuration = $this->getConfiguration($configs, $container);
34 3
        $config = $this->processConfiguration($configuration, $configs);
0 ignored issues
show
Documentation introduced by
$configuration 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...
35
36 3
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
37 3
        $loader->load('services.xml');
38
39 3
        if (method_exists('Symfony\Component\DependencyInjection\Definition', 'setFactory')) {
40 3
            $loader->load('services-2.7.xml');
41
        } else {
42
            $loader->load('services-2.6.xml');
43
        }
44
45 3
        $twigBundleLoaded = isset($bundles['TwigBundle']);
46 3
        $twigExtensionLoaded = class_exists('Puli\TwigExtension\PuliExtension');
47 3
        $twigEnabled = $config['twig'];
48
49 3
        if ($twigBundleLoaded && $twigExtensionLoaded && $twigEnabled) {
50 1
            $loader->load('twig.xml');
51
        }
52 3
    }
53
}
54