DynamicConsumerCommand::initConsumer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
/**
4
 * DynamicConsumerCommand
5
 * 
6
 * The context argument is passed to the consumer instance
7
 * which can decide about the queue and routings it uses.
8
 *
9
 * @author Tibor Barna <[email protected]>
10
 */
11
namespace OldSound\RabbitMqBundle\Command;
12
13
use Symfony\Component\Console\Input\InputArgument;
14
15
class DynamicConsumerCommand extends BaseConsumerCommand
16
{
17 1
    protected function configure()
18
    {
19 1
        parent::configure();
20
21
        $this
22 1
            ->setName('rabbitmq:dynamic-consumer')
23 1
            ->setDescription('Executes context-aware consumer')
24 1
            ->addArgument('context', InputArgument::REQUIRED, 'Context the consumer runs in')
25
            ;
26 1
    }
27
28
    protected function getConsumerService()
29
    {
30
        return 'old_sound_rabbit_mq.%s_dynamic';
31
    }
32
33
    protected function initConsumer($input)
34
    {
35
        parent::initConsumer($input);
36
        $this->consumer->setContext($input->getArgument('context'));
37
    }
38
}
39