Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| Buffer | |
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getContents | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| append | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| render | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __toString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| jsonSerialize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php declare(strict_types=1); |
| 2 | |
| 3 | namespace Computator\FrameworkUtils\PHPTemplate\RenderTree; |
| 4 | |
| 5 | use JsonSerializable; |
| 6 | use Stringable; |
| 7 | |
| 8 | class Buffer implements Renderable, Stringable, JsonSerializable { |
| 9 | public function __construct( |
| 10 | protected string $value = '', |
| 11 | ) {} |
| 12 | |
| 13 | public function getContents(): string { |
| 14 | return $this->value; |
| 15 | } |
| 16 | |
| 17 | public function append(string $data): void { |
| 18 | $this->value .= $data; |
| 19 | } |
| 20 | |
| 21 | public function render(): void { |
| 22 | echo $this->value; |
| 23 | } |
| 24 | |
| 25 | public function __toString(): string { |
| 26 | return $this->getContents(); |
| 27 | } |
| 28 | |
| 29 | public function jsonSerialize(): mixed { |
| 30 | return $this->getContents(); |
| 31 | } |
| 32 | } |