Total Complexity | 13 |
Total Lines | 123 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
7 | class Process implements \JsonSerializable |
||
8 | { |
||
9 | /** |
||
10 | * Process ID of the service |
||
11 | * |
||
12 | * @var int |
||
13 | */ |
||
14 | private $pid; |
||
15 | |||
16 | /** |
||
17 | * Parent process ID of the service |
||
18 | * |
||
19 | * @var int|null |
||
20 | */ |
||
21 | private $ppid; |
||
22 | |||
23 | /** |
||
24 | * @var string|null |
||
25 | */ |
||
26 | private $title; |
||
27 | |||
28 | /** |
||
29 | * Command line arguments used to start this process |
||
30 | * |
||
31 | * @var array|null |
||
32 | */ |
||
33 | private $argv; |
||
34 | |||
35 | /** |
||
36 | * @param int $pid |
||
37 | * @param int|null $ppid |
||
38 | * @param string|null $title |
||
39 | * @param array|null $argv |
||
40 | */ |
||
41 | 17 | public function __construct($pid, $ppid = null, $title = null, array $argv = null) |
|
42 | { |
||
43 | 17 | $this->assertArgv($argv); |
|
44 | |||
45 | 16 | $this->pid = $pid; |
|
46 | 16 | $this->ppid = $ppid; |
|
47 | 16 | $this->title = $title; |
|
48 | 16 | $this->argv = $argv; |
|
49 | 16 | } |
|
50 | |||
51 | /** |
||
52 | * @return int |
||
53 | */ |
||
54 | 1 | public function pid() |
|
55 | { |
||
56 | 1 | return $this->pid; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * @return int|null |
||
61 | */ |
||
62 | 1 | public function ppid() |
|
63 | { |
||
64 | 1 | return $this->ppid; |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * @return string|null |
||
69 | */ |
||
70 | 1 | public function title() |
|
71 | { |
||
72 | 1 | return $this->title; |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return array|null |
||
77 | */ |
||
78 | 1 | public function argv() |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * @return Process |
||
85 | */ |
||
86 | 13 | public static function discover() |
|
97 | 13 | ); |
|
98 | } |
||
99 | |||
100 | /** |
||
101 | * @param array|null $argv |
||
102 | * |
||
103 | * @return void |
||
104 | * |
||
105 | * @throws \InvalidArgumentException |
||
106 | */ |
||
107 | 17 | private function assertArgv($argv) |
|
116 | } |
||
117 | 15 | } |
|
118 | 15 | } |
|
119 | |||
120 | /** |
||
121 | * @return array |
||
122 | */ |
||
123 | 1 | public function jsonSerialize() |
|
133 |