Total Complexity | 10 |
Total Lines | 138 |
Duplicated Lines | 0 % |
Coverage | 91.89% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class Process |
||
8 | { |
||
9 | |||
10 | /** |
||
11 | * error |
||
12 | * |
||
13 | * @var Boolean |
||
14 | */ |
||
15 | private $error; |
||
16 | |||
17 | /** |
||
18 | * error message |
||
19 | * |
||
20 | * @var String |
||
21 | */ |
||
22 | private $errorMesage; |
||
23 | |||
24 | /** |
||
25 | * command to execute |
||
26 | * |
||
27 | * @var String |
||
28 | */ |
||
29 | private $command; |
||
30 | |||
31 | /** |
||
32 | * execute ouput |
||
33 | * |
||
34 | * @var String |
||
35 | */ |
||
36 | private $result; |
||
37 | |||
38 | |||
39 | /** |
||
40 | * instanciate |
||
41 | */ |
||
42 | 8 | public function __construct() |
|
43 | { |
||
44 | 8 | $this->reset(); |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * set command to be executed |
||
49 | * |
||
50 | * @param string $command |
||
51 | * @return Process |
||
52 | */ |
||
53 | 2 | public function setCommand(string $command): Process |
|
54 | { |
||
55 | 2 | $this->reset(); |
|
56 | 2 | $this->command = $command; |
|
57 | 2 | return $this; |
|
58 | } |
||
59 | |||
60 | /** |
||
61 | * return string result for a given system command |
||
62 | * |
||
63 | * @param string $command |
||
64 | * @return string |
||
65 | */ |
||
66 | 1 | public function run(): Process |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * return true if error |
||
93 | * |
||
94 | * @return boolean |
||
95 | */ |
||
96 | 2 | public function isError(): bool |
|
97 | { |
||
98 | 2 | return $this->error === true; |
|
99 | } |
||
100 | |||
101 | /** |
||
102 | * returns error message |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | 1 | public function getErrorMessage(): string |
|
107 | { |
||
108 | 1 | return $this->errorMesage; |
|
109 | } |
||
110 | |||
111 | /** |
||
112 | * return execute result as string |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | 2 | public function __toString() |
|
119 | } |
||
120 | |||
121 | /** |
||
122 | * reset errors |
||
123 | * |
||
124 | * @return Process |
||
125 | */ |
||
126 | 1 | protected function reset(): Process |
|
132 | } |
||
133 | |||
134 | /** |
||
135 | * return pipes descriptors |
||
136 | * |
||
137 | * @return array |
||
138 | */ |
||
139 | 1 | protected function getDescriptors(): array |
|
145 | ]; |
||
146 | } |
||
147 | } |
||
148 |