RegisterCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 36
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
getDefinitionName() 0 1 ?
getTagName() 0 1 ?
getMethodName() 0 1 ?
A process() 0 15 3
1
<?php
2
3
namespace Zenstruck\BackupBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
/**
10
 * @author Kevin Bond <[email protected]>
11
 */
12
abstract class RegisterCompilerPass implements CompilerPassInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 10
    final public function process(ContainerBuilder $container)
18
    {
19 10
        $definitionName = $this->getDefinitionName();
20
21 10
        if (false === $container->hasDefinition($definitionName)) {
22 5
            return;
23
        }
24
25 5
        $definition = $container->getDefinition($definitionName);
26 5
        $taggedServices = $container->findTaggedServiceIds($this->getTagName());
27
28 5
        foreach (array_keys($taggedServices) as $id) {
29 5
            $definition->addMethodCall($this->getMethodName(), array(new Reference($id)));
30
        }
31 5
    }
32
33
    /**
34
     * @return string
35
     */
36
    abstract protected function getDefinitionName();
37
38
    /**
39
     * @return string
40
     */
41
    abstract protected function getTagName();
42
43
    /**
44
     * @return string
45
     */
46
    abstract protected function getMethodName();
47
}
48