Completed
Branch master (38bcb9)
by Matthew
02:36
created

ResetCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 19
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 9 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
    protected function configure()
12
    {
13
        $this
14
            ->setName('dtc:queue:reset')
15
            ->setDescription('Reset jobs with error or stalled status');
16
    }
17
18
    protected function execute(InputInterface $input, OutputInterface $output)
19
    {
20
        $container = $this->getContainer();
21
        $jobManager = $container->get('dtc_queue.job_manager');
22
        $countError = $jobManager->resetErroneousJobs();
23
        $countStalled = $jobManager->resetStalledJobs();
24
        $output->writeln("$countError job(s) in status 'error' reset");
25
        $output->writeln("$countStalled job(s) in status 'running' reset");
26
    }
27
}
28