Completed
Pull Request — master (#20)
by Wachter
05:08
created

RunCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
crap 2
1
<?php
2
3
/*
4
 * This file is part of php-task library.
5
 *
6
 * (c) php-task
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Task\TaskBundle\Command;
13
14
use Symfony\Component\Console\Command\Command;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
use Task\Runner\TaskRunnerInterface;
18
use Task\Scheduler\TaskSchedulerInterface;
19
20
/**
21
 * Run pending tasks.
22
 */
23
class RunCommand extends Command
24
{
25
    /**
26
     * @var TaskRunnerInterface
27
     */
28
    private $runner;
29
30
    /**
31
     * @var TaskSchedulerInterface
32
     */
33
    private $scheduler;
34
35
    /**
36
     * @param string $name
37
     * @param TaskRunnerInterface $runner
38
     * @param TaskSchedulerInterface $scheduler
39
     */
40
    public function __construct($name, TaskRunnerInterface $runner, TaskSchedulerInterface $scheduler)
41
    {
42
        parent::__construct($name);
43
44
        $this->runner = $runner;
45
        $this->scheduler = $scheduler;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    protected function configure()
52
    {
53
        $this->setDescription('Run pending tasks');
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    protected function execute(InputInterface $input, OutputInterface $output)
60
    {
61
        $this->runner->runTasks();
62
        $this->scheduler->scheduleTasks();
63
    }
64
}
65