Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
87.50% |
7 / 8 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
DisplayResultHelper | |
87.50% |
7 / 8 |
|
0.00% |
0 / 1 |
3.02 | |
0.00% |
0 / 1 |
__construct | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
displayResult | |
87.50% |
7 / 8 |
|
0.00% |
0 / 1 |
2.01 |
1 | <?php |
2 | namespace Apie\Console\Helpers; |
3 | |
4 | use Symfony\Component\VarDumper\Cloner\VarCloner; |
5 | use Symfony\Component\VarDumper\Dumper\CliDumper; |
6 | |
7 | final class DisplayResultHelper |
8 | { |
9 | /** |
10 | * @codeCoverageIgnore |
11 | */ |
12 | private function __construct() |
13 | { |
14 | } |
15 | |
16 | public static function displayResult(mixed $result): string |
17 | { |
18 | if (is_string($result)) { |
19 | return $result; |
20 | } |
21 | $cloner = new VarCloner(); |
22 | $stream = tmpfile(); |
23 | $dumper = new CliDumper($stream); |
24 | |
25 | $dumper->dump($cloner->cloneVar($result)); |
26 | rewind($stream); |
27 | return stream_get_contents($stream); |
28 | } |
29 | } |