Completed
Branch master (b0f294)
by MediaMonks
03:42
created

AbstractPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A addMethodCallToCrawler() 0 13 3
1
<?php
2
3
namespace MediaMonks\CrawlerBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
abstract class AbstractPass implements CompilerPassInterface
10
{
11
    /**
12
     * @param ContainerBuilder $container
13
     * @param string $tag
14
     * @param string $methodName
15
     */
16 6
    protected function addMethodCallToCrawler(ContainerBuilder $container, $tag, $methodName)
17
    {
18 6
        if (!$container->hasDefinition('mediamonks_crawler.crawler')) {
19 2
            return;
20
        }
21
22 4
        $definition = $container->findDefinition('mediamonks_crawler.crawler');
23
24 4
        $taggedServices = $container->findTaggedServiceIds($tag);
25 4
        foreach ($taggedServices as $id => $tags) {
26 3
            $definition->addMethodCall($methodName, [new Reference($id)]);
27 4
        }
28 4
    }
29
}
30