Completed
Push — master ( c2e487...7ac6a5 )
by Wachter
07:39
created

ScheduleTaskCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 1
cbo 4
dl 0
loc 35
ccs 15
cts 15
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A configure() 0 7 1
A execute() 0 6 1
1
<?php
2
3
namespace Task\TaskBundle\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Task\SchedulerInterface;
10
11
/**
12
 * Schedule task.
13
 *
14
 * @author @wachterjohannes <[email protected]>
15
 */
16
class ScheduleTaskCommand extends Command
17
{
18
    /**
19
     * @var SchedulerInterface
20
     */
21
    private $scheduler;
22
23 3
    public function __construct(SchedulerInterface $scheduler)
24
    {
25 3
        parent::__construct('task:schedule:task');
26
27 3
        $this->scheduler = $scheduler;
28 3
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 3
    protected function configure()
34
    {
35 3
        $this
36 3
            ->setDescription('Run pending tasks')
37 3
            ->addArgument('handler', InputArgument::REQUIRED)
38 3
            ->addArgument('workload', InputArgument::OPTIONAL);
39 3
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 2
    protected function execute(InputInterface $input, OutputInterface $output)
45
    {
46 2
        $this->scheduler
47 2
            ->createTask($input->getArgument('handler'), $input->getArgument('workload'))
48 2
            ->schedule();
49 2
    }
50
}
51