ProcessorCompilerPass::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 3
eloc 10
nc 3
nop 1
1
<?php
2
3
namespace Kasifi\PdfParserBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
/**
10
 * Class ProcessorCompilerPass.
11
 */
12
class ProcessorCompilerPass implements CompilerPassInterface
13
{
14
    public function process(ContainerBuilder $container)
15
    {
16
        if (!$container->has('kasifi_pdfparser.pdf_parser')) {
17
            return;
18
        }
19
20
        $definition = $container->findDefinition(
21
            'kasifi_pdfparser.pdf_parser'
22
        );
23
24
        $taggedServices = $container->findTaggedServiceIds('kasifi_pdfparser.processor');
25
        foreach ($taggedServices as $id => $tags) {
26
            $definition->addMethodCall(
27
                'addAvailableProcessor',
28
                [new Reference($id)]
29
            );
30
        }
31
    }
32
}
33