-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Buffered Console Output (#36404)
* add buffered console output * Apply fixes from StyleCI (#36403) * change visibility
- Loading branch information
1 parent
50b4a94
commit 8a14453
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Illuminate\Console; | ||
|
||
use Symfony\Component\Console\Output\ConsoleOutput; | ||
|
||
class BufferedConsoleOutput extends ConsoleOutput | ||
{ | ||
/** | ||
* The current buffer. | ||
* | ||
* @var string | ||
*/ | ||
protected $buffer = ''; | ||
|
||
/** | ||
* Empties the buffer and returns its content. | ||
* | ||
* @return string | ||
*/ | ||
public function fetch() | ||
{ | ||
return tap($this->buffer, function () { | ||
$this->buffer = ''; | ||
}); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function doWrite(string $message, bool $newline) | ||
{ | ||
$this->buffer .= $message; | ||
|
||
if ($newline) { | ||
$this->buffer .= \PHP_EOL; | ||
} | ||
|
||
return parent::doWrite($message, $newline); | ||
} | ||
} |