Completed
Pull Request — master (#26)
by Julien
04:20
created

UnlockCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 13
loc 13
ccs 0
cts 13
cp 0
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Itkg\DelayEventBundle\Command;
4
5
use Itkg\DelayEventBundle\Handler\LockHandlerInterface;
6
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * Class UnlockCommand
13
 */
14
class UnlockCommand extends ContainerAwareCommand
15
{
16
    /**
17
     * @var LockHandlerInterface
18
     */
19
    private $lockHandler;
20
21
    /**
22
     * @param LockHandlerInterface $lockHandler
23
     * @param null|string          $name
24
     */
25
    public function __construct(
26
        LockHandlerInterface $lockHandler, $name = null)
27
    {
28
        $this->lockHandler = $lockHandler;
29
30
        parent::__construct($name);
31
    }
32
33
    /**
34
     * {@inheritDoc}
35
     */
36 View Code Duplication
    protected function configure()
0 ignored issues
show
Duplication introduced by
This method 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...
37
    {
38
        $this
39
            ->setName('itkg_delay_event:unlock')
40
            ->setDescription('Unlock command')
41
            ->addOption(
42
                'channel',
43
                'c',
44
                InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
45
                'Specify the channels to unlock (default: [\'default\'])',
46
                ['default']
47
            );
48
    }
49
50
    /**
51
     * @param InputInterface  $input
52
     * @param OutputInterface $output
53
     *
54
     * @return int|null|void
55
     */
56
    protected function execute(InputInterface $input, OutputInterface $output)
57
    {
58
        foreach ($input->getOption('channel') as $channel) {
59
            $this->lockHandler->release($channel);
60
            $output->writeln(sprintf(
61
                'Channel <info>%s</info> unlocked.',
62
                $channel
63
            ));
64
        }
65
    }
66
}
67