Buffer.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: yunwuxin <448901948@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace think\console\output\driver;
  12. use think\console\Output;
  13. class Buffer
  14. {
  15. /**
  16. * @var string
  17. */
  18. private $buffer = '';
  19. public function __construct(Output $output)
  20. {
  21. // do nothing
  22. }
  23. public function fetch()
  24. {
  25. $content = $this->buffer;
  26. $this->buffer = '';
  27. return $content;
  28. }
  29. public function write($messages, $newline = false, $options = Output::OUTPUT_NORMAL)
  30. {
  31. $messages = (array) $messages;
  32. foreach ($messages as $message) {
  33. $this->buffer .= $message;
  34. }
  35. if ($newline) {
  36. $this->buffer .= "\n";
  37. }
  38. }
  39. public function renderException(\Exception $e)
  40. {
  41. // do nothing
  42. }
  43. }