Completed
Push — master ( 8a683b...96b103 )
by Matthew
05:26 queued 53s
created

ResetCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 8
cts 8
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Dtc\QueueBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class ResetCommand extends ContainerAwareCommand
10
{
11 1
    protected function configure()
12
    {
13 1
        $this
14 1
            ->setName('dtc:queue:reset')
15 1
            ->setDescription('Reset jobs with error or stalled status');
16 1
    }
17
18 1
    protected function execute(InputInterface $input, OutputInterface $output)
19
    {
20 1
        $container = $this->getContainer();
21 1
        $jobManager = $container->get('dtc_queue.job_manager');
22 1
        $countError = $jobManager->resetErroneousJobs();
23 1
        $countStalled = $jobManager->resetStalledJobs();
24 1
        $output->writeln("$countError job(s) in status 'error' reset");
25 1
        $output->writeln("$countStalled job(s) in status 'running' reset");
26 1
    }
27
}
28