Failed Conditions
Push — feature/improve ( 14cb7b )
by Yo
06:33
created

AbstractExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 48
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildContainerId() 0 8 1
A createService() 0 20 3
1
<?php
2
namespace Yoanm\Behat3SymfonyExtension\ServiceContainer;
3
4
use Behat\Testwork\ServiceContainer\Extension;
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Definition;
7
8
abstract class AbstractExtension implements Extension
9
{
10
    const BASE_CONTAINER_ID = 'behat3_symfony_extension';
11
    const KERNEL_SERVICE_ID = 'behat3_symfony_extension.kernel';
12
13
    /**
14
     * @param string $key
15
     *
16
     * @return string
17
     */
18 8
    protected function buildContainerId($key)
19
    {
20 8
        return sprintf(
21 8
            '%s.%s',
22 8
            self::BASE_CONTAINER_ID,
23
            $key
24 8
        );
25
    }
26
27
    /**
28
     * @param ContainerBuilder $container
29
     * @param string           $id
30
     * @param string           $class
31
     * @param array            $argumentList
32
     * @param array            $tagList
33
     * @param array            $addMethodCallList
34
     */
35 5
    protected function createService(
36
        ContainerBuilder $container,
37
        $id,
38
        $class,
39
        $argumentList = array(),
40
        $tagList = array(),
41
        $addMethodCallList = array()
42
    ) {
43 5
        $definition = new Definition($class, $argumentList);
44
45 5
        foreach ($tagList as $tag) {
46 3
            $definition->addTag($tag);
47 5
        }
48
49 5
        foreach ($addMethodCallList as $methodCall) {
50 1
            $definition->addMethodCall($methodCall[0], $methodCall[1]);
51 5
        }
52
53 5
        $container->setDefinition($this->buildContainerId($id), $definition);
54 5
    }
55
}
56