StartCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 31
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 0 13 3
1
<?php
2
3
namespace MyOnlineStore\Bundle\RabbitMqManagerBundle\Command;
4
5
use MyOnlineStore\Bundle\RabbitMqManagerBundle\Exception\Supervisor\SupervisorAlreadyRunningException;
6
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
final class StartCommand extends ContainerAwareCommand
12
{
13
    /**
14
     * @inheritdoc
15
     */
16 3
    protected function configure()
17
    {
18 3
        $this
19 3
            ->setName('rabbitmq-manager:start')
20 3
            ->setDescription('start supervisord')
21 3
            ->addOption('generate', null, InputOption::VALUE_NONE, 'Generate configuration files before starting')
22
        ;
23 3
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28 3
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30 3
        if ($input->getOption('generate')) {
31 2
            $this->getContainer()->get('myonlinestore_rabbitmq_manager.config_generator')->generate();
32 2
        }
33
34
        try {
35 3
            $this->getContainer()->get('myonlinestore_rabbitmq_manager.supervisor')->start();
36 2
            $output->writeln('Supervisord is started');
37 3
        } catch (SupervisorAlreadyRunningException $exception) {
38 1
            $output->writeln(sprintf('<error>%s</error>', $exception->getMessage()));
39
        }
40 3
    }
41
}
42