Completed
Push — master ( 68e873...04562c )
by Tomasz
05:18
created

RabbitMqWorkerRunner   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 25
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 18 3
1
<?php
2
3
namespace Gendoria\CommandQueueRabbitMqDriverBundle\Worker;
4
5
use Gendoria\CommandQueueBundle\Worker\WorkerRunnerInterface;
6
use InvalidArgumentException;
7
use Symfony\Bundle\FrameworkBundle\Console\Application;
8
use Symfony\Component\Console\Input\ArrayInput;
9
use Symfony\Component\Console\Output\NullOutput;
10
use Symfony\Component\Console\Output\OutputInterface;
11
use Symfony\Component\DependencyInjection\ContainerInterface;
12
13
/**
14
 * Description of RabbitMqWorkerRunner
15
 *
16
 * @author Tomasz Struczyński <[email protected]>
17
 */
18
class RabbitMqWorkerRunner implements WorkerRunnerInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23 2
    public function run(array $options, ContainerInterface $container, OutputInterface $output = null)
24
    {
25 2
        if (empty($options['consumer_name'])) {
26 1
            throw new InvalidArgumentException("Options array has to contain consumer_name.");
27
        }
28 1
        if (!$output) {
29 1
            $output = new NullOutput();
30 1
        }
31 1
        $kernel = $container->get('kernel');
32 1
        $application = new Application($kernel);
33 1
        $application->setAutoExit(false);
34 1
        $input = new ArrayInput(array(
35 1
            'command' => 'rabbitmq:consumer',
36 1
            '-w' => null,
37 1
            'name' => $options['consumer_name'],
38 1
        ));
39 1
        $application->run($input, $output);
40 1
    }
41
42
}
43