HelperPass::process()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 13
cts 13
cp 1
rs 9.568
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4
1
<?php
2
3
namespace JaySDe\HandlebarsBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class HelperPass implements CompilerPassInterface
10
{
11 2
    public function process(ContainerBuilder $container)
12
    {
13 2
        if (!$container->has('handlebars.helper')) {
14 1
            return;
15
        }
16
17 1
        $definition = $container->findDefinition(
18 1
            'handlebars.helper'
19
        );
20
21 1
        $taggedServices = $container->findTaggedServiceIds(
22 1
            'handlebars.helper'
23
        );
24 1
        foreach ($taggedServices as $id => $tags) {
25 1
            foreach ($tags as $tag) {
26 1
                $definition->addMethodCall(
27 1
                    'addHelper',
28 1
                    array($tag['id'], new Reference($id))
29
                );
30
            }
31
        }
32 1
    }
33
}
34