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

ScheduleTaskCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
crap 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