Conditions | 1 |
Paths | 1 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
17 | function childProcessPromise(LoopInterface $loop, Process $process) |
||
18 | { |
||
19 | 1 | $deferred = new Deferred(); |
|
20 | $buffers = [ |
||
21 | 1 | 'stderr' => '', |
|
22 | 1 | 'stdout' => '', |
|
23 | 1 | ]; |
|
24 | |||
25 | $process->on('exit', function ($exitCode) use ($deferred, &$buffers) { |
||
26 | 1 | $deferred->resolve(new ProcessOutcome($exitCode, $buffers['stderr'], $buffers['stdout'])); |
|
27 | 1 | }); |
|
28 | |||
29 | \WyriHaximus\React\futurePromise($loop, $process)->then(function (Process $process) use ($loop, &$buffers) { |
||
30 | 1 | $process->start($loop); |
|
31 | $process->stderr->on('data', function ($output) use (&$buffers) { |
||
32 | 1 | $buffers['stderr'] .= $output; |
|
33 | 1 | }); |
|
34 | $process->stdout->on('data', function ($output) use (&$buffers) { |
||
35 | 1 | $buffers['stdout'] .= $output; |
|
36 | 1 | }); |
|
37 | 1 | }); |
|
38 | |||
39 | 1 | return $deferred->promise(); |
|
40 | } |
||
41 |