You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
853 B

3 years ago
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Console\Output;
  11. /**
  12. * @author Jean-François Simon <contact@jfsimon.fr>
  13. */
  14. class BufferedOutput extends Output
  15. {
  16. private $buffer = '';
  17. /**
  18. * Empties buffer and returns its content.
  19. *
  20. * @return string
  21. */
  22. public function fetch()
  23. {
  24. $content = $this->buffer;
  25. $this->buffer = '';
  26. return $content;
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. protected function doWrite(string $message, bool $newline)
  32. {
  33. $this->buffer .= $message;
  34. if ($newline) {
  35. $this->buffer .= \PHP_EOL;
  36. }
  37. }
  38. }