Completed
Push — develop ( a73fad...2d5c57 )
by Baptiste
10:58
created

InnmindRestServerExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 6
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 14 1
A registerTypes() 0 13 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Rest\ServerBundle\DependencyInjection;
5
6
use Symfony\Component\{
7
    HttpKernel\DependencyInjection\Extension,
8
    DependencyInjection\ContainerBuilder,
9
    DependencyInjection\Loader,
10
    Config\FileLocator
11
};
12
13
final class InnmindRestServerExtension extends Extension
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function load(array $configs, ContainerBuilder $container)
19
    {
20
        $loader = new Loader\YamlFileLoader(
21
            $container,
22
            new FileLocator(__DIR__ . '/../Resources/config')
23
        );
24
        $loader->load('services.yml');
25
        $config = $this->processConfiguration(
26
            new Configuration,
27
            $configs
28
        );
29
30
        $this->registerTypes($config['types'], $container);
31
    }
32
33
    /**
34
     * @return void
35
     */
36
    private function registerTypes(array $types, ContainerBuilder $container)
37
    {
38
        $definition = $container->getDefinition(
39
            'innmind_rest_server.definition.types'
40
        );
41
42
        foreach ($types as $type) {
43
            $definition->addMethodCall(
44
                'register',
45
                [$type]
46
            );
47
        }
48
    }
49
}
50