PHP 8.3.31
Preview: TrimmedBufferOutput.php Size: 1.52 KB
/home/getspomw/royalsquad.us/vendor/symfony/console/Output/TrimmedBufferOutput.php

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Console\Output;

use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;

/**
 * A BufferedOutput that keeps only the last N chars.
 *
 * @author Jérémy Derussé <jeremy@derusse.com>
 */
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);
    }
}

Directory Contents

Dirs: 0 × Files: 11

Name Size Perms Modified Actions
3.41 KB lrw-rw-rw- 2025-09-17 06:53:23
Edit Download
808 B lrw-rw-rw- 2025-09-17 06:53:23
Edit Download
4.64 KB lrw-rw-rw- 2025-09-17 06:53:23
Edit Download
785 B lrw-rw-rw- 2025-09-17 06:53:23
Edit Download
8.20 KB lrw-rw-rw- 2025-09-17 06:53:23
Edit Download
10.10 KB lrw-r--r-- 2026-04-26 10:00:22
Edit Download
1.96 KB lrw-rw-rw- 2025-09-17 06:53:23
Edit Download
4.18 KB lrw-rw-rw- 2025-09-17 06:53:23
Edit Download
2.74 KB lrw-rw-rw- 2025-09-17 06:53:23
Edit Download
4.11 KB lrw-rw-rw- 2025-09-17 06:53:23
Edit Download
1.52 KB lrw-rw-rw- 2025-09-17 06:53:23
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).