QueueDeleteCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
namespace Tavii\SQSJobQueueBundle\Command;
3
4
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
5
use Symfony\Component\Console\Input\InputArgument;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Tavii\SQSJobQueue\Queue\QueueName;
10
11
class QueueDeleteCommand extends ContainerAwareCommand
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    protected function configure()
17
    {
18
        $this->setName('sqs_job_queue:queue-delete')
19
            ->setDescription('list queue')
20
            ->addArgument('queue', InputArgument::REQUIRED, 'queue name')
21
        ;
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function execute(InputInterface $input, OutputInterface $output)
28
    {
29
        $client = $this->getContainer()->get('sqs_job_queue.client');
30
        $queueName = new QueueName($input->getArgument('queue'), $this->getContainer()->getParameter('sqs_job_queue.prefix'));
31
32
        $result = $client->getQueueUrl(array(
33
            'QueueName' => $queueName->getQueueName()
34
        ));
35
36
        $dialog = $this->getHelper('dialog');
37
        $ret = $dialog->askConfirmation(
38
            $output,
39
            "<question>{$queueName->getQueueName()} delete queue?[yes or no]</question> ",
40
            true
41
        );
42
43 View Code Duplication
        if ($ret) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
            $client->deleteQueue(array(
45
                'QueueUrl' => $result['QueueUrl']
46
            ));
47
            $output->writeln('<info>delete queue url</info>: '. $result['QueueUrl']);
48
        } else {
49
            $output->writeln('cancel purge...');
50
        }
51
    }
52
53
}