ClearQueueCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 5
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 11 1
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