WorkerStopCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
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 View Code Duplication
class WorkerStopCommand extends ContainerAwareCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
12
{
13
    protected function configure()
14
    {
15
        $this->setName('sqs_job_queue:worker-stop')
16
            ->setDescription('Stop a sqs worker')
17
            ->addArgument('queue', InputArgument::REQUIRED, 'Queue name')
18
            ->addOption('pid', 'p', InputOption::VALUE_OPTIONAL, 'stop pid name', null)
19
            ->addOption('force', 'f', InputOption::VALUE_NONE, 'force storage delete')
20
        ;
21
    }
22
23
    protected function execute(InputInterface $input, OutputInterface $output)
24
    {
25
        $queueName = new QueueName($input->getArgument('queue'), $this->getContainer()->getParameter('sqs_job_queue.prefix'));
26
        $worker = $this->getContainer()->get('sqs_job_queue.worker');
27
        $worker->stop($queueName, $input->getOption('pid'), $input->getOption('force'));
28
    }
29
}