QueueDeclareCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php
2
3
namespace TreeHouse\QueueBundle\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use TreeHouse\QueueBundle\CacheWarmer\AmqpCacheWarmer;
9
10
class QueueDeclareCommand extends Command
11
{
12
    /**
13
     * @var AmqpCacheWarmer
14
     */
15
    private $cacheWarmer;
16
17
    /**
18
     * @param AmqpCacheWarmer $cacheWarmer
19
     */
20
    public function __construct(AmqpCacheWarmer $cacheWarmer)
21
    {
22
        parent::__construct();
23
24
        $this->cacheWarmer = $cacheWarmer;
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30
    protected function configure()
31
    {
32
        $this->setName('queue:declare');
33
        $this->setDescription('Tries to declare all known exchanges and queues');
34
        $this->setHelp(<<<HELP
35
This utility command is useful for deployments to ensure all the configured
36
exchanges and queues are created on the message broker.
37
HELP
38
        );
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44
    protected function execute(InputInterface $input, OutputInterface $output)
45
    {
46
        $this->cacheWarmer->warmUp('');
47
48
        $output->writeln('<info>All exchanges and queues are declared</info>');
49
    }
50
}
51