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

Process::isRunning()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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