QueueCreateCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 0 14 1
1
<?php
2
namespace Tavii\SQSJobQueueBundle\Command;
3
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\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Tavii\SQSJobQueue\Queue\QueueName;
11
12
class QueueCreateCommand extends ContainerAwareCommand
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    protected function configure()
18
    {
19
        $this->setName('sqs_job_queue:queue-create')
20
            ->setDescription('create queue')
21
            ->addArgument('queue', InputArgument::REQUIRED, 'queue name')
22
            ->addOption('delaySec', 'S', InputOption::VALUE_OPTIONAL, 'DelaySeconds', 0)
23
        ;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function execute(InputInterface $input, OutputInterface $output)
30
    {
31
        $prefix = $this->getContainer()->getParameter('sqs_job_queue.prefix');
0 ignored issues
show
Unused Code introduced by
$prefix is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
32
        $client = $this->getContainer()->get('sqs_job_queue.client');
33
34
        $queueName = new QueueName($input->getArgument('queue'), $this->getContainer()->getParameter('sqs_job_queue.prefix'));
35
        $client->createQueue(array(
36
            'QueueName' => $queueName->getQueueName(),
37
            'Attributes' => array(
38
                'DelaySeconds' => $input->getOption('delaySec')
39
            ),
40
        ));
41
        $output->writeln('<info>SUCCESS:</info> '.$queueName->getQueueName());
42
    }
43
}