Passed
Pull Request — master (#2)
by Vincent
04:15 queued 01:21
created

BdfQueueBundle::build()

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
nc 1
nop 1
dl 0
loc 15
ccs 8
cts 8
cp 1
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A BdfQueueBundle.php$0 ➔ process() 0 12 3
1
<?php
2
3
namespace Bdf\QueueBundle;
4
5
use Bdf\QueueBundle\FailerFactory\FailerFactory;
6
use Bdf\QueueBundle\FailerFactory\PrimeFailerFactory;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Reference;
10
use Symfony\Component\HttpKernel\Bundle\Bundle;
11
12
/**
13
 * BdfQueueBundle
14
 *
15
 * @author Seb
16
 */
17
class BdfQueueBundle extends Bundle
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22 3
    public function build(ContainerBuilder $container)
23
    {
24
        $container->addCompilerPass(new class implements CompilerPassInterface {
25 2
            public function process(ContainerBuilder $container)
26
            {
27
                // Enable prime failer
28 2
                if (PrimeFailerFactory::supported() && $container->has('prime')) {
29 2
                    $container->register(PrimeFailerFactory::class)
30 2
                        ->setClass(PrimeFailerFactory::class)
31 2
                        ->setArguments([new Reference('prime')])
32
                    ;
33
34
                    // @todo init command ?
35 2
                    $container->findDefinition(FailerFactory::class)
36 2
                        ->addMethodCall('register', [new Reference(PrimeFailerFactory::class)]);
37
                }
38 2
            }
39
        });
40 3
    }
41
}
42