Total Complexity | 5 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class BufferedOutput implements OutputStream |
||
9 | { |
||
10 | private $buffer = ''; |
||
11 | |||
12 | public function write(string $buffer): void |
||
13 | { |
||
14 | $this->buffer .= $buffer; |
||
15 | } |
||
16 | |||
17 | public function fetch(bool $clean = true) : string |
||
18 | { |
||
19 | $buffer = $this->buffer; |
||
20 | |||
21 | if ($clean) { |
||
22 | $this->buffer = ''; |
||
23 | } |
||
24 | |||
25 | return $buffer; |
||
26 | } |
||
27 | |||
28 | public function __toString() : string |
||
29 | { |
||
30 | return $this->fetch(); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Whether the stream is connected to an interactive terminal |
||
35 | */ |
||
36 | public function isInteractive() : bool |
||
39 | } |
||
40 | } |
||
41 |