1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Conia\Boiler; |
||
6 | |||
7 | class Section |
||
8 | { |
||
9 | /** @var list<string> */ |
||
10 | protected array $prepended = []; |
||
11 | |||
12 | /** @var list<string> */ |
||
13 | protected array $appended = []; |
||
14 | |||
15 | 3 | public function __construct(protected string $value) |
|
16 | { |
||
17 | 3 | } |
|
18 | |||
19 | 2 | public function prepend(string $content): self |
|
20 | { |
||
21 | 2 | $this->prepended[] = $content; |
|
22 | |||
23 | 2 | return $this; |
|
24 | } |
||
25 | |||
26 | 2 | public function append(string $content): self |
|
27 | { |
||
28 | 2 | array_unshift($this->appended, $content); |
|
29 | |||
30 | 2 | return $this; |
|
31 | } |
||
32 | |||
33 | 1 | public function empty(): bool |
|
34 | { |
||
35 | 1 | error_log(print_r($this->value, true)); |
|
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
36 | |||
37 | 1 | return empty($this->value); |
|
38 | } |
||
39 | |||
40 | 3 | public function get(): string |
|
41 | { |
||
42 | 3 | return implode('', array_merge($this->prepended, [$this->value], $this->appended)); |
|
43 | } |
||
44 | |||
45 | 1 | public function setValue(string $value): void |
|
46 | { |
||
47 | 1 | $this->value = $value; |
|
48 | } |
||
49 | } |
||
50 |