BackgroundProcessRunner   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 16 2
1
<?php namespace Indatus\Dispatcher;
2
3
/**
4
 * This file is part of Dispatcher
5
 *
6
 * (c) Ben Kuhl <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
use Indatus\Dispatcher\Scheduling\ScheduledCommandInterface;
13
use Indatus\Dispatcher\Services\CommandService;
14
15
class BackgroundProcessRunner
16
{
17
    /**
18
     * @var \Indatus\Dispatcher\Services\CommandService
19
     */
20
    private $commandService;
21
22 5
    public function __construct(CommandService $commandService)
23
    {
24 5
        $this->commandService = $commandService;
25 5
    }
26
27
    /**
28
     * Run a scheduled command
29
     *
30
     * @param  \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface $scheduledCommand
31
     * @param  array                                                    $arguments
32
     * @param  array                                                    $options
33
     * @return bool
34
     */
35 2
    public function run(
36
        ScheduledCommandInterface $scheduledCommand,
37
        array $arguments = [],
38
        array $options = [],
39
        Debugger $debugger = null
40
    ) {
41 2
        $runCommand = $this->commandService->getRunCommand($scheduledCommand, $arguments, $options);
42
43 2
        if (!is_null($debugger)) {
44 1
            $debugger->commandRun($scheduledCommand, $runCommand);
45 1
        }
46
47 2
        exec($runCommand);
48
49 2
        return true;
50
    }
51
}
52