Completed
Push — master ( 8a683b...96b103 )
by Matthew
05:26 queued 53s
created

BeanstalkdCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 12
cts 12
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
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('Pheanstalk\\Pheanstalk',
16 1
                [$container->getParameter('dtc_queue.beanstalkd.host')]);
17 1
            $container->setDefinition('dtc_queue.beanstalkd', $definition);
18 1
            $definition = $container->getDefinition('dtc_queue.job_manager.beanstalkd');
19 1
            $definition->addMethodCall('setBeanstalkd', [new Reference('dtc_queue.beanstalkd')]);
20 1
            if ($container->hasParameter('dtc_queue.beanstalkd.tube')) {
21 1
                $definition->addMethodCall('setTube', [$container->getParameter('dtc_queue.beanstalkd.tube')]);
22 1
            }
23 1
        }
24 1
    }
25
}
26