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

anonymous//BdfQueueBundle.php$0   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 7
cts 7
cp 1
c 0
b 0
f 0
rs 10
wmc 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