Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | public static function readFromProcess(string $command): string |
||
15 | { |
||
16 | if (!\function_exists('proc_open')) { |
||
17 | return null; |
||
18 | } |
||
19 | $descriptorspec = [ |
||
20 | 1 => ['pipe', 'w'], |
||
21 | 2 => ['pipe', 'w'], |
||
22 | ]; |
||
23 | $process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => false]); |
||
24 | if (!\is_resource($process)) { |
||
25 | return null; |
||
26 | } |
||
27 | $info = stream_get_contents($pipes[1]); |
||
28 | |||
29 | fclose($pipes[1]); |
||
30 | fclose($pipes[2]); |
||
31 | proc_close($process); |
||
32 | return $info; |
||
33 | } |
||
35 |