Completed
Push — master ( 96809c...29a8a1 )
by Danny
02:46
created

StartCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 93.33%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 31
ccs 14
cts 15
cp 0.9333
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
class StartCommand extends ContainerAwareCommand
12
{
13
    /**
14
     * @inheritdoc
15
     */
16 2
    protected function configure()
17
    {
18 2
        $this
19 2
            ->setName('rabbitmq-manager:start')
20 2
            ->setDescription('start supervisord')
21 2
            ->addOption('generate', null, InputOption::VALUE_NONE, 'Generate configuration files before starting')
22
        ;
23 2
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28 2
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30 2
        if ($input->getOption('generate')) {
31 1
            $this->getContainer()->get('myonlinestore_rabbitmq_manager.config_generator')->generate();
32 1
        }
33
34
        try {
35 2
            $this->getContainer()->get('myonlinestore_rabbitmq_manager.supervisor')->start();
36 2
            $output->writeln('Supervisord is started');
37 2
        } catch (SupervisorAlreadyRunningException $exception) {
38
            $output->writeln(sprintf('<error>%s</error>', $exception->getMessage()));
39
        }
40 2
    }
41
}
42