| Total Complexity | 8 |
| Total Lines | 67 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | final class Hint extends Widget |
||
| 17 | { |
||
| 18 | use FormAttributeTrait; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @psalm-var non-empty-string |
||
| 22 | */ |
||
| 23 | private string $tag = 'div'; |
||
| 24 | private array $tagAttributes = []; |
||
| 25 | |||
| 26 | private string|Stringable|null $content = null; |
||
| 27 | |||
| 28 | private bool $encode = true; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Set the container tag name for the hint. |
||
| 32 | * |
||
| 33 | * @param string $tag Container tag name. |
||
| 34 | */ |
||
| 35 | 5 | public function tag(string $tag): self |
|
| 36 | { |
||
| 37 | 5 | if ($tag === '') { |
|
| 38 | 1 | throw new InvalidArgumentException('Tag name cannot be empty.'); |
|
| 39 | } |
||
| 40 | |||
| 41 | 4 | $new = clone $this; |
|
| 42 | 4 | $new->tag = $tag; |
|
| 43 | 4 | return $new; |
|
| 44 | } |
||
| 45 | |||
| 46 | 4 | public function tagAttributes(array $attributes): self |
|
| 47 | { |
||
| 48 | 4 | $new = clone $this; |
|
| 49 | 4 | $new->tagAttributes = $attributes; |
|
| 50 | 4 | return $new; |
|
| 51 | } |
||
| 52 | |||
| 53 | 7 | public function content(string|Stringable|null $content): self |
|
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Whether content should be HTML-encoded. |
||
| 62 | * |
||
| 63 | * @param bool $value |
||
| 64 | */ |
||
| 65 | 2 | public function encode(bool $value): self |
|
| 66 | { |
||
| 67 | 2 | $new = clone $this; |
|
| 68 | 2 | $new->encode = $value; |
|
| 69 | 2 | return $new; |
|
| 70 | } |
||
| 71 | |||
| 72 | 422 | protected function run(): string |
|
| 83 | } |
||
| 84 | } |
||
| 85 |