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