Conditions | 3 |
Paths | 3 |
Total Lines | 23 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 3.0416 |
Changes | 0 |
1 | <?php |
||
66 | 1 | public function run(): Process |
|
67 | { |
||
68 | 1 | if (!\function_exists('proc_open')) { |
|
69 | $this->error = true; |
||
70 | $this->errorMesage = 'undefined function proc_open'; |
||
71 | return null; |
||
72 | } |
||
73 | 1 | $this->error = true; |
|
74 | 1 | $this->errorMesage = 'process is not a resource'; |
|
75 | 1 | $process = proc_open( |
|
76 | 1 | $this->command, |
|
77 | 1 | $this->getDescriptors(), |
|
78 | $pipes |
||
79 | ); |
||
80 | 1 | if (is_resource($process)) { |
|
81 | 1 | $this->result = stream_get_contents($pipes[1]); |
|
82 | 1 | $this->errorMesage = stream_get_contents($pipes[2]); |
|
83 | 1 | $this->error = !empty($this->errorMesage); |
|
84 | 1 | fclose($pipes[1]); |
|
85 | 1 | fclose($pipes[2]); |
|
86 | 1 | proc_close($process); |
|
87 | } |
||
88 | 1 | return $this; |
|
89 | } |
||
148 |