Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
25 | public function run(CodeBlock $codeBlock): OutcomeInterface |
||
26 | { |
||
27 | $filename = tempnam(sys_get_temp_dir(), 'doctestphp'); |
||
28 | |||
29 | file_put_contents($filename, "<?php $codeBlock"); |
||
30 | |||
31 | $process = new PhpProcess("<?php {$this->bootstrapCode} require '$filename';"); |
||
32 | $process->run(); |
||
33 | |||
34 | unlink($filename); |
||
35 | |||
36 | if ($errorOutput = $process->getErrorOutput()) { |
||
37 | return new ErrorOutcome(trim($errorOutput)); |
||
38 | } |
||
39 | |||
40 | if ($output = $process->getOutput()) { |
||
41 | return new OutputOutcome($output); |
||
42 | } |
||
43 | |||
44 | return new VoidOutcome; |
||
45 | } |
||
47 |