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
12
namespace OldSound\RabbitMqBundle\Command;
13
14
use Symfony\Component\Console\Input\InputArgument;
15
use Symfony\Component\Console\Input\InputInterface;
16
17
class DynamicConsumerCommand extends BaseConsumerCommand
18
{
19 1
    protected function configure(): void
20
    {
21 1
        parent::configure();
22
23
        $this
24 1
            ->setName('rabbitmq:dynamic-consumer')
25 1
            ->setDescription('Executes context-aware consumer')
26 1
            ->addArgument('context', InputArgument::REQUIRED, 'Context the consumer runs in')
27
        ;
28 1
    }
29
30
    protected function getConsumerService()
31
    {
32
        return 'old_sound_rabbit_mq.%s_dynamic';
33
    }
34
35
    protected function initConsumer(InputInterface $input)
36
    {
37
        parent::initConsumer($input);
38
        $this->consumer->setContext($input->getArgument('context'));
39
    }
40
}
41