Completed
Push — master ( 836114...b3a960 )
by Matthew
08:40
created

BeanstalkdCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 10
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Dtc\QueueBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\Definition;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class BeanstalkdCompilerPass implements CompilerPassInterface
11
{
12 1
    public function process(ContainerBuilder $container)
13
    {
14 1
        if ($container->hasParameter('dtc_queue.beanstalkd.host')) {
15 1
            $definition = new Definition(
16 1
                'Pheanstalk\\Pheanstalk',
17 1
                [$container->getParameter('dtc_queue.beanstalkd.host')]
18
            );
19 1
            $container->setDefinition('dtc_queue.beanstalkd', $definition);
20 1
            $definition = $container->getDefinition('dtc_queue.job_manager.beanstalkd');
21 1
            $definition->addMethodCall('setBeanstalkd', [new Reference('dtc_queue.beanstalkd')]);
22 1
            if ($container->hasParameter('dtc_queue.beanstalkd.tube')) {
23 1
                $definition->addMethodCall('setTube', [$container->getParameter('dtc_queue.beanstalkd.tube')]);
24
            }
25
        }
26 1
    }
27
}
28