Completed
Push — master ( 60e340...59674f )
by Tomasz
04:54
created

ListWorkersCommand::formatRunnerName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Gendoria\CommandQueueBundle\Command;
4
5
use Gendoria\CommandQueueBundle\Worker\WorkerRunnerManager;
6
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * Description of RunWorkerCommand
13
 *
14
 * @author Tomasz Struczyński <[email protected]>
15
 */
16
class ListWorkersCommand extends ContainerAwareCommand
17
{
18
19 1
    protected function configure()
20
    {
21 1
        $this->setName('command-queue:list-workers')
22 1
            ->setDescription('List available workers');
23 1
    }
24
25 1
    public function execute(InputInterface $input, OutputInterface $output)
26
    {
27
        /* @var $workerRunnerService WorkerRunnerManager */
28 1
        $workerRunnerService = $this->getContainer()->get('gendoria_command_queue.runner_manager');
29 1
        $runners = $workerRunnerService->getRunners();
30 1
        $runnersFormatted = array_map(array($this, 'formatRunnerName'), $runners);
31 1
        $output->writeln('Registered workers:');
32 1
        $output->writeln($runnersFormatted);
33 1
    }
34
35 1
    public function formatRunnerName($name)
36
    {
37 1
        return sprintf("  * <info>%s</info>", $name);
38
    }
39
40
}
41