| Total Complexity | 9 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 13 | class StdErrOutputAdapter implements OutputInterface |
||
| 14 | { |
||
| 15 | /** @var resource */ |
||
| 16 | protected $stream; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * StdErrOutputAdapter constructor. |
||
| 20 | * @param mixed $stream |
||
| 21 | */ |
||
| 22 | public function __construct($stream = STDERR) |
||
| 30 | } |
||
| 31 | |||
| 32 | |||
| 33 | /** {@inheritDoc} */ |
||
| 34 | public function write($messages, $newline = false, $options = 0): void |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Writes a message to STDERR. |
||
| 46 | * |
||
| 47 | * @param string $message A message to write to STDERR |
||
| 48 | * @param bool $newline Whether to add a newline or not |
||
| 49 | */ |
||
| 50 | protected function doWrite(string $message, bool $newline): void |
||
| 51 | { |
||
| 52 | if ($newline) { |
||
| 53 | $message .= PHP_EOL; |
||
| 54 | } |
||
| 55 | |||
| 56 | if (false === @fwrite($this->stream, $message)) { |
||
| 57 | // should never happen |
||
| 58 | throw new \RuntimeException('Unable to write output.'); |
||
| 59 | } |
||
| 60 | |||
| 61 | fflush($this->stream); |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return resource |
||
| 66 | */ |
||
| 67 | public function getStream() |
||
| 70 | } |
||
| 71 | } |
||
| 72 |