Completed
Pull Request — master (#47)
by Wachter
06:41 queued 17s
created

ExecutionProcessFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Task\TaskBundle\Executor;
4
5
use Symfony\Component\Process\Process;
6
use Symfony\Component\Process\ProcessBuilder;
7
8
/**
9
 * Factory for execution-process.
10
 */
11
class ExecutionProcessFactory
12
{
13
    /**
14
     * @var string
15
     */
16
    private $consolePath;
17
18
    /**
19
     * @var string
20
     */
21
    private $environment;
22
23
    /**
24
     * @var float|null
25
     */
26
    private $processTimeout;
27
28
    /**
29
     * @param string $consolePath
30
     * @param float|null $processTimeout
31
     * @param string $environment
32
     */
33
    public function __construct($consolePath, $processTimeout, $environment)
34
    {
35
        $this->consolePath = $consolePath;
36
        $this->processTimeout = $processTimeout;
37
        $this->environment = $environment;
38
    }
39
40
    /**
41
     * Create process for given execution-uuid.
42
     *
43
     * @param string $uuid
44
     *
45
     * @return Process
46
     */
47
    public function create($uuid)
48
    {
49
        return $process = ProcessBuilder::create(
0 ignored issues
show
Unused Code introduced by
$process is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
50
                [$this->consolePath, 'task:execute', $uuid, '--env=' . $this->environment]
51
            )
52
            ->setTimeout($this->processTimeout)
53
            ->getProcess();
54
    }
55
}
56