Passed
Push — master ( 130df2...007dfb )
by Alexis
10:23
created

LiipFunctionalTestExtension::load()   A

Complexity

Conditions 5
Paths 6

Size

Total Lines 31

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 15
cts 15
cp 1
rs 9.1128
c 0
b 0
f 0
cc 5
nc 6
nop 2
crap 5
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Liip/FunctionalTestBundle
7
 *
8
 * (c) Lukas Kahwe Smith <[email protected]>
9
 *
10
 * This source file is subject to the MIT license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13
14
namespace Liip\FunctionalTestBundle\DependencyInjection;
15
16
use Symfony\Component\Config\FileLocator;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
19
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
20
21
class LiipFunctionalTestExtension extends Extension
22
{
23
    /**
24
     * Loads the services based on your application configuration.
25
     *
26
     * @param array            $configs
27
     * @param ContainerBuilder $container
28
     */
29 4
    public function load(array $configs, ContainerBuilder $container): void
30
    {
31 4
        $config = $this->processConfiguration(new Configuration(), $configs);
32
33 4
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
34 4
        $loader->load('functional_test.xml');
35
36 4
        if (interface_exists('Symfony\Component\Validator\Validator\ValidatorInterface')) {
37 4
            $loader->load('validator.xml');
38
        }
39
40 4
        foreach ($config as $key => $value) {
41
            // If the node is an array,
42
            // e.g. "liip_functional_test.query.max_query_count",
43
            // set the value as
44
            // "liip_functional_test.query.max_query_count"
45
            // instead of an array "liip_functional_test.query"
46
            // with a "max_query_count" key.
47 4
            if (is_array($value)) {
48 4
                foreach ($value as $key2 => $value2) {
49 4
                    $container->setParameter($this->getAlias().'.'.$key.
50 4
                        '.'.$key2, $value2);
51
                }
52
            } else {
53 4
                $container->setParameter($this->getAlias().'.'.$key, $value);
54
            }
55
        }
56
57 4
        $definition = $container->getDefinition('liip_functional_test.query.count_client');
58 4
        $definition->setShared(false);
59 4
    }
60
}
61