ConsoleBufferedOutput   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 10
c 1
b 0
f 1
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fetch() 0 9 2
A doWrite() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Console\Output;
6
7
use Symfony\Component\Console\Output\ConsoleOutput;
8
9
final class ConsoleBufferedOutput extends ConsoleOutput
10
{
11
    private string $buffer = '';
12
13
    /**
14
     * Returns buffer content optionally clearing it.
15
     */
16 4
    public function fetch(bool $clearBuffer = false): string
17
    {
18 4
        $content = $this->buffer;
19
20 4
        if ($clearBuffer) {
21 1
            $this->buffer = '';
22
        }
23
24 4
        return $content;
25
    }
26
27 2
    protected function doWrite(string $message, bool $newline): void
28
    {
29 2
        $this->buffer .= $message;
30
31 2
        if ($newline) {
32 1
            $this->buffer .= PHP_EOL;
33
        }
34
35 2
        parent::doWrite($message, $newline);
36
    }
37
}
38