OctanteNatsExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 5
Bugs 1 Features 2
Metric Value
wmc 1
c 5
b 1
f 2
lcom 0
cbo 7
dl 0
loc 33
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 0 26 1
1
<?php
2
3
/*
4
 * This file is part of the NatsBundle package.
5
 *
6
 * (c) Issel Guberna <[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 Octante\NatsBundle\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Processor;
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Definition;
18
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
19
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
20
21
class OctanteNatsExtension extends Extension
22
{
23
    /**
24
     * @param array            $configs
25
     * @param ContainerBuilder $container
26
     */
27
    public function load(array $configs, ContainerBuilder $container)
28
    {
29
        $processor = new Processor();
30
        $configuration = new Configuration();
31
        $config = $processor->processConfiguration($configuration, $configs);
32
33
        $loader = new YamlFileLoader(
34
            $container,
35
            new FileLocator(__DIR__.'/../Resources/config')
36
        );
37
        $loader->load('services.yml');
38
39
        // Connection instance
40
        $connectionFactoryDefinition = new Definition(
41
            'Octante\\NatsBundle\\Services\\ConnectionFactory',
42
            [
43
                $config['connections'],
44
                $container->getDefinition('nats.logger')
45
            ]
46
        );
47
48
        $container->setDefinition(
49
            'octante_nats.connection_factory',
50
            $connectionFactoryDefinition
51
        );
52
    }
53
}
54