Completed
Pull Request — master (#47)
by Wachter
11:23
created

RunCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 49
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A configure() 0 11 1
A execute() 0 5 1
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
            ->setHelp(<<<'EOT'
55
The <info>%command.name%</info> command runs the pending task-executions. During the execution the status
56
of the executions will be updated.
57
58
    $ %command.full_name%
59
EOT
60
            );
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    protected function execute(InputInterface $input, OutputInterface $output)
67
    {
68
        $this->runner->runTasks();
69
        $this->scheduler->scheduleTasks();
70
    }
71
}
72