QueueListCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 2
1
<?php
2
namespace Tavii\SQSJobQueueBundle\Command;
3
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class QueueListCommand extends ContainerAwareCommand
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    protected function configure()
16
    {
17
        $this->setName('sqs_job_queue:queue-list')
18
            ->setDescription('list queue')
19
            ->addOption('queueNamePrefix', 'Q',InputOption::VALUE_OPTIONAL, 'QueueNamePrefix', '')
20
        ;
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function execute(InputInterface $input, OutputInterface $output)
27
    {
28
        $client = $this->getContainer()->get('sqs_job_queue.client');
29
        $results = $client->listQueues(array(
30
            'QueueNamePrefix' => $input->getOption('queueNamePrefix'),
31
        ));
32
33
        foreach ($results['QueueUrls'] as $queueUrl) {
34
            $output->writeln("<info>queue url:</info> $queueUrl");
35
        }
36
    }
37
}