| Total Complexity | 11 |
| Total Lines | 83 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | final class Label extends Widget |
||
| 13 | { |
||
| 14 | use FormAttributeTrait; |
||
| 15 | |||
| 16 | private bool $setForAttribute = true; |
||
| 17 | |||
| 18 | private ?string $forId = null; |
||
| 19 | private bool $useInputIdAttribute = true; |
||
| 20 | |||
| 21 | private string|Stringable|null $content = null; |
||
| 22 | |||
| 23 | private bool $encode = true; |
||
| 24 | |||
| 25 | 4 | public function setForAttribute(bool $value): self |
|
| 26 | { |
||
| 27 | 4 | $new = clone $this; |
|
| 28 | 4 | $new->setForAttribute = $value; |
|
| 29 | 4 | return $new; |
|
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @return static |
||
| 34 | */ |
||
| 35 | 4 | public function forId(?string $id): self |
|
| 36 | { |
||
| 37 | 4 | $new = clone $this; |
|
| 38 | 4 | $new->forId = $id; |
|
| 39 | 4 | return $new; |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @return static |
||
| 44 | */ |
||
| 45 | 5 | public function useInputIdAttribute(bool $value): self |
|
| 46 | { |
||
| 47 | 5 | $new = clone $this; |
|
| 48 | 5 | $new->useInputIdAttribute = $value; |
|
| 49 | 5 | return $new; |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return static |
||
| 54 | */ |
||
| 55 | 7 | public function content(string|Stringable|null $content): self |
|
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Whether content should be HTML-encoded. |
||
| 64 | * |
||
| 65 | * @return static |
||
| 66 | */ |
||
| 67 | 1 | public function encode(bool $value): self |
|
| 68 | { |
||
| 69 | 1 | $new = clone $this; |
|
| 70 | 1 | $new->encode = $value; |
|
| 71 | 1 | return $new; |
|
| 72 | } |
||
| 73 | |||
| 74 | 42 | protected function run(): string |
|
| 95 | } |
||
| 96 | } |
||
| 97 |