SetupFabricCommand   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 15
c 3
b 0
f 1
dl 0
loc 31
ccs 0
cts 24
cp 0
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 20 5
1
<?php
2
3
namespace OldSound\RabbitMqBundle\Command;
4
5
use OldSound\RabbitMqBundle\RabbitMq\DynamicConsumer;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class SetupFabricCommand extends BaseRabbitMqCommand
11
{
12
    protected function configure()
13
    {
14
        $this
15
            ->setName('rabbitmq:setup-fabric')
16
            ->setDescription('Sets up the Rabbit MQ fabric')
17
            ->addOption('debug', 'd', InputOption::VALUE_NONE, 'Enable Debugging')
18
        ;
19
    }
20
21
    protected function execute(InputInterface $input, OutputInterface $output)
22
    {
23
        if (defined('AMQP_DEBUG') === false) {
24
            define('AMQP_DEBUG', (bool) $input->getOption('debug'));
25
        }
26
27
        $output->writeln('Setting up the Rabbit MQ fabric');
28
29
        $partsHolder = $this->getContainer()->get('old_sound_rabbit_mq.parts_holder');
30
31
        foreach (array('base_amqp', 'binding') as $key) {
32
            foreach ($partsHolder->getParts('old_sound_rabbit_mq.' . $key) as $baseAmqp) {
33
                if ($baseAmqp instanceof DynamicConsumer) {
34
                    continue;
35
                }
36
                $baseAmqp->setupFabric();
37
            }
38
        }
39
40
        return 0;
41
42
    }
43
}
44