class TrimmedBufferOutput
A BufferedOutput that keeps only the last N chars.
@author Jérémy Derussé <jeremy@derusse.com>
Hierarchy
- class \Symfony\Component\Console\Output\Output implements \Symfony\Component\Console\Output\OutputInterface
- class \Symfony\Component\Console\Output\TrimmedBufferOutput extends \Symfony\Component\Console\Output\Output
Expanded class hierarchy of TrimmedBufferOutput
1 file declares its use of TrimmedBufferOutput
- SymfonyStyle.php in vendor/
symfony/ console/ Style/ SymfonyStyle.php
File
-
vendor/
symfony/ console/ Output/ TrimmedBufferOutput.php, line 22
Namespace
Symfony\Component\Console\OutputView source
class TrimmedBufferOutput extends Output {
private int $maxLength;
private string $buffer = '';
public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, ?OutputFormatterInterface $formatter = null) {
if ($maxLength <= 0) {
throw new InvalidArgumentException(\sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength));
}
parent::__construct($verbosity, $decorated, $formatter);
$this->maxLength = $maxLength;
}
/**
* Empties buffer and returns its content.
*/
public function fetch() : string {
$content = $this->buffer;
$this->buffer = '';
return $content;
}
protected function doWrite(string $message, bool $newline) : void {
$this->buffer .= $message;
if ($newline) {
$this->buffer .= \PHP_EOL;
}
$this->buffer = substr($this->buffer, -$this->maxLength);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
Output::$formatter | private | property | |||
Output::$verbosity | private | property | |||
Output::getFormatter | public | function | Returns current output formatter instance. | Overrides OutputInterface::getFormatter | |
Output::getVerbosity | public | function | Gets the current verbosity of the output. | Overrides OutputInterface::getVerbosity | |
Output::isDebug | public | function | Returns whether verbosity is debug (-vvv). | Overrides OutputInterface::isDebug | |
Output::isDecorated | public | function | Gets the decorated flag. | Overrides OutputInterface::isDecorated | |
Output::isQuiet | public | function | Returns whether verbosity is quiet (-q). | Overrides OutputInterface::isQuiet | |
Output::isSilent | public | function | |||
Output::isVerbose | public | function | Returns whether verbosity is verbose (-v). | Overrides OutputInterface::isVerbose | |
Output::isVeryVerbose | public | function | Returns whether verbosity is very verbose (-vv). | Overrides OutputInterface::isVeryVerbose | |
Output::setDecorated | public | function | Sets the decorated flag. | Overrides OutputInterface::setDecorated | 1 |
Output::setFormatter | public | function | Overrides OutputInterface::setFormatter | 1 | |
Output::setVerbosity | public | function | Sets the verbosity of the output. | Overrides OutputInterface::setVerbosity | 1 |
Output::write | public | function | Writes a message to the output. | Overrides OutputInterface::write | |
Output::writeln | public | function | Writes a message to the output and adds a newline at the end. | Overrides OutputInterface::writeln | |
OutputInterface::OUTPUT_NORMAL | public | constant | |||
OutputInterface::OUTPUT_PLAIN | public | constant | |||
OutputInterface::OUTPUT_RAW | public | constant | |||
OutputInterface::VERBOSITY_DEBUG | public | constant | |||
OutputInterface::VERBOSITY_NORMAL | public | constant | |||
OutputInterface::VERBOSITY_QUIET | public | constant | |||
OutputInterface::VERBOSITY_SILENT | public | constant | |||
OutputInterface::VERBOSITY_VERBOSE | public | constant | |||
OutputInterface::VERBOSITY_VERY_VERBOSE | public | constant | |||
TrimmedBufferOutput::$buffer | private | property | |||
TrimmedBufferOutput::$maxLength | private | property | |||
TrimmedBufferOutput::doWrite | protected | function | Writes a message to the output. | Overrides Output::doWrite | |
TrimmedBufferOutput::fetch | public | function | Empties buffer and returns its content. | ||
TrimmedBufferOutput::__construct | public | function | Overrides Output::__construct |