AbstractPass::addMethodCallToCrawler()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.4285
cc 3
eloc 7
nc 3
nop 3
crap 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 5
    protected function addMethodCallToCrawler(ContainerBuilder $container, $tag, $methodName)
17
    {
18 5
        if (!$container->hasDefinition('mediamonks_crawler.crawler')) {
19 2
            return;
20
        }
21
22 3
        $definition = $container->findDefinition('mediamonks_crawler.crawler');
23
24 3
        $taggedServices = $container->findTaggedServiceIds($tag);
25 3
        foreach ($taggedServices as $id => $tags) {
26 3
            $definition->addMethodCall($methodName, [new Reference($id)]);
27 3
        }
28 3
    }
29
}
30