Completed
Push — master ( 381036...d6bde4 )
by Alexander
19:09
created

ExecutionProcessFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 90.91%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A create() 0 12 2
1
<?php
2
3
namespace Task\TaskBundle\Executor;
4
5
use Symfony\Component\Process\Process;
6
7
/**
8
 * Factory for execution-process.
9
 */
10
class ExecutionProcessFactory
11
{
12
    /**
13
     * @var string
14
     */
15
    private $consolePath;
16
17
    /**
18
     * @var string
19
     */
20
    private $environment;
21
22
    /**
23
     * @var float|null
24
     */
25
    private $processTimeout;
26
27
    /**
28
     * @param string $consolePath
29
     * @param float|null $processTimeout
30
     * @param string $environment
31
     */
32 13
    public function __construct($consolePath, $processTimeout, $environment)
33
    {
34 13
        $this->consolePath = $consolePath;
35 13
        $this->processTimeout = $processTimeout;
36 13
        $this->environment = $environment;
37 13
    }
38
39
    /**
40
     * Create process for given execution-uuid.
41
     *
42
     * @param string $uuid
43
     *
44
     * @return Process
45
     */
46 2
    public function create($uuid)
47
    {
48 2
        $command = implode(' ', [$this->consolePath, 'task:execute', $uuid, '--env=' . $this->environment]);
49
50 2
        if (method_exists(Process::class, 'fromShellCommandline')) {
51 2
            $process = Process::fromShellCommandline($command);
52
        } else {
53
            $process = new Process($command);
0 ignored issues
show
Documentation introduced by
$command is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
54
        }
55
56 2
        return $process->setTimeout($this->processTimeout);
57
    }
58
}
59