InnmindHomeostasisExtension::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 55
Code Lines 42

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 38
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 55
ccs 38
cts 38
cp 1
rs 9.7692
c 0
b 0
f 0
cc 1
eloc 42
nc 1
nop 2
crap 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\HomeostasisBundle\DependencyInjection;
5
6
use Symfony\Component\{
7
    HttpKernel\DependencyInjection\Extension,
8
    DependencyInjection\ContainerBuilder,
9
    DependencyInjection\Loader,
10
    DependencyInjection\Reference,
11
    Config\FileLocator
12
};
13
14
final class InnmindHomeostasisExtension extends Extension
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19 2
    public function load(array $configs, ContainerBuilder $container)
20
    {
21 2
        $loader = new Loader\YamlFileLoader(
22 2
            $container,
23 2
            new FileLocator(__DIR__.'/../Resources/config')
24
        );
25 2
        $loader->load('services.yml');
26 2
        $config = $this->processConfiguration(
27 2
            new Configuration,
28 2
            $configs
29
        );
30
31 2
        $container->setParameter(
32 2
            'innmind.homeostasis.factors',
33 2
            $config['factors']
34
        );
35 2
        $container->setParameter(
36 2
            'innmind.homeostasis.regulator_stack',
37 2
            $config['regulator_stack']
38
        );
39 2
        $container->setAlias(
40 2
            'innmind.homeostasis.strategy_determinator',
41 2
            $config['strategy_determinator']
42
        );
43
        $container
44 2
            ->getDefinition('innmind.homeostasis.regulator.default')
45 2
            ->replaceArgument(
46 2
                4,
47 2
                new Reference($config['actuator'])
48
            );
49
        $container
50 2
            ->getDefinition('innmind.homeostasis.state_history.filesystem')
51 2
            ->replaceArgument(
52 2
                0,
53 2
                $config['state_history']
54
            );
55
        $container
56 2
            ->getDefinition('innmind.homeostasis.action_history.filesystem')
57 2
            ->replaceArgument(
58 2
                0,
59 2
                $config['action_history']
60
            );
61
        $container
62 2
            ->getDefinition('innmind.homeostasis.regulator.modulate_state_history.max_history')
63 2
            ->replaceArgument(
64 2
                0,
65 2
                $config['max_history']
66
            );
67
        $container
68 2
            ->getDefinition('innmind.homeostasis.regulator.modulate_state_history.min_history')
69 2
            ->replaceArgument(
70 2
                0,
71 2
                $config['min_history']
72
            );
73 2
    }
74
}
75