ClearQueueCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Mpclarkson\ResqueBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * Class ClearQueueCommand
12
 * @package Mpclarkson\ResqueBundle\Command
13
 */
14
class ClearQueueCommand extends ContainerAwareCommand
15
{
16
    /**
17
     *
18
     */
19
    protected function configure()
20
    {
21
        $this
22
            ->setName('resque:clear-queue')
23
            ->setDescription('Clear a resque queue')
24
            ->addArgument('queue', InputArgument::REQUIRED, 'Queue name');
25
    }
26
27
    /**
28
     * @param InputInterface $input
29
     * @param OutputInterface $output
30
     * @return int
31
     */
32
    protected function execute(InputInterface $input, OutputInterface $output)
33
    {
34
        $resque = $this->getContainer()->get('resque');
35
36
        $queue = $input->getArgument('queue');
37
        $count = $resque->clearQueue($queue);
38
39
        $output->writeln('Cleared queue ' . $queue . ' - removed ' . $count . ' entries');
40
41
        return 0;
42
    }
43
}
44