BufferedOutput.php 904 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. /**
  17. * @var string
  18. */
  19. private $buffer = '';
  20. /**
  21. * Empties buffer and returns its content.
  22. */
  23. public function fetch()
  24. {
  25. $content = $this->buffer;
  26. $this->buffer = '';
  27. return $content;
  28. }
  29. /**
  30. * @return void
  31. * @param string $message
  32. * @param bool $newline
  33. */
  34. protected function doWrite($message, $newline)
  35. {
  36. $this->buffer .= $message;
  37. if ($newline) {
  38. $this->buffer .= \PHP_EOL;
  39. }
  40. }
  41. }