<?php

namespace Kylin\Admin\Support;

use Symfony\Component\Console\Output\Output;

class StringOutput extends Output
{
    public $output = '';

    public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, $formatter = null)
    {
        $formatter = $formatter ?: new OutputFormatter();

        parent::__construct($verbosity, $decorated, $formatter);
    }

    public function clear()
    {
        $this->output = '';
    }

    protected function doWrite($message, $newline): void
    {
        $this->output .= $message . ($newline ? "\n" : '');
    }

    public function getContent()
    {
        return trim($this->output);
    }
}
