PhuriaUnderQueryExtension::load()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 10
cts 10
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 2
crap 2
1
<?php
2
3
/**
4
 * This file is part of UnderQuery package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
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 Phuria\UnderQueryBundle\DependencyInjection;
13
14
use Phuria\UnderQuery\UnderQuery;
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
18
use Symfony\Component\DependencyInjection\Reference;
19
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
20
21
/**
22
 * @author Beniamin Jonatan Šimko <[email protected]>
23
 */
24
class PhuriaUnderQueryExtension extends Extension
25
{
26
    /**
27
     * @inheritdoc
28
     */
29 1
    public function load(array $configs, ContainerBuilder $container)
30
    {
31 1
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
32 1
        $loader->load('services.xml');
33 1
        $processedConfig = $this->processConfiguration(new Configuration(), $configs);
34
35 1
        $underQueryDefinition = $container->register('phuria_under_query', UnderQuery::class);
36
37 1
        if ($connection = $processedConfig['connection']) {
38 1
            $underQueryDefinition->addArgument(new Reference($connection));
39 1
        }
40
41 1
        $container->setAlias('under_query', 'phuria_under_query');
42
    }
43
}