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

AbstractExtension::buildContainerId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 1
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