Completed
Push — master ( 0513f3...46cdfb )
by Daniel
03:05
created

RpcServicePass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A process() 0 13 1
1
<?php
2
3
namespace Cmobi\RabbitmqBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Definition;
8
9
class RpcServicePass implements CompilerPassInterface
10
{
11
    private $serviceName;
12
    private $serviceClass;
13
    private $queueOptions;
14
    private $params;
15
16
    public function __construct($serviceName, $serviceClass, array $queueOptions, array $params = [])
17
    {
18
        $this->serviceName = $serviceName;
19
        $this->serviceClass = $serviceClass;
20
        $this->queueOptions = $queueOptions;
21
        $this->params = $params;
22
    }
23
24
    public function process(ContainerBuilder $container)
25
    {
26
        $rpcHandler = $container->getDefinition('cmobi_rabbitmq.rpc.handler');
27
        $definition = new Definition(
28
            $this->serviceClass,
29
            [
30
                'handler' => $rpcHandler,
31
                'queueOptions' => $this->params,
32
                'parameters' => $this->queueOptions
33
            ]
34
        );
35
        $container->setDefinition($this->serviceName, $definition);
36
    }
37
}