Passed
Push — master ( 1b561f...b63c2d )
by Daniel
03:23 queued 12s
created

Process   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 11
c 0
b 0
f 0
dl 0
loc 49
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A start() 0 9 2
A getCommand() 0 3 1
A __construct() 0 4 1
A isRunning() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jellyfish\ProcessSymfony;
6
7
use Jellyfish\Process\ProcessInterface;
8
use Symfony\Component\Process\Process as SymfonyProcess;
9
10
class Process implements ProcessInterface
11
{
12
    /**
13
     * @var array
14
     */
15
    protected $command;
16
17
    /**
18
     * @var \Symfony\Component\Process\Process
19
     */
20
    protected $process;
21
22
    /**
23
     * @param array $command
24
     */
25
    public function __construct(array $command)
26
    {
27
        $this->command = $command;
28
        $this->process = new SymfonyProcess($command);
29
    }
30
31
    /**
32
     * @return \Jellyfish\Process\ProcessInterface
33
     */
34
    public function start(): ProcessInterface
35
    {
36
        if ($this->isRunning()) {
37
            return $this;
38
        }
39
40
        $this->process->start();
41
42
        return $this;
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    public function getCommand(): array
49
    {
50
        return $this->command;
51
    }
52
53
    /**
54
     * @return bool
55
     */
56
    public function isRunning(): bool
57
    {
58
        return $this->process->isRunning();
59
    }
60
}
61