Conditions | 3 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
48 | public static function getStdin(InputInterface $input): string |
||
49 | { |
||
50 | // If testing this will get input added by `CommandTester::setInputs` method. |
||
51 | $inputSteam = ($input instanceof StreamableInputInterface) ? $input->getStream() : null; |
||
52 | |||
53 | // If nothing from input stream use STDIN instead. |
||
54 | $inputSteam = $inputSteam ?? \STDIN; |
||
55 | |||
56 | $input = stream_get_contents($inputSteam); |
||
57 | |||
58 | if (false === $input) { |
||
59 | // No way of easily testing this |
||
60 | throw new SarbException('Can not read input stream'); // @codeCoverageIgnore |
||
61 | } |
||
62 | |||
63 | return $input; |
||
64 | } |
||
74 |