Completed
Pull Request — master (#15)
by Wachter
06:01
created

RunCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 6
Bugs 2 Features 0
Metric Value
wmc 3
c 6
b 2
f 0
lcom 1
cbo 3
dl 0
loc 42
ccs 0
cts 12
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A configure() 0 4 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\SchedulerInterface;
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 SchedulerInterface
32
     */
33
    private $scheduler;
34
35
    /**
36
     * @param string $name
37
     * @param TaskRunnerInterface $runner
38
     * @param SchedulerInterface $scheduler
39
     */
40
    public function __construct($name, TaskRunnerInterface $runner, SchedulerInterface $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