| Total Complexity | 9 |
| Total Lines | 105 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | final class Button extends Widget |
||
| 21 | { |
||
| 22 | private string $tagName = 'button'; |
||
| 23 | private string $label = 'Button'; |
||
| 24 | private bool $encodeLabels = true; |
||
| 25 | private bool $encodeTags = false; |
||
| 26 | private array $options = []; |
||
| 27 | 8 | ||
| 28 | public function run(): string |
||
| 47 | ); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Whether the label should be HTML-encoded. |
||
| 52 | 8 | * |
|
| 53 | * @param bool $value |
||
| 54 | 8 | * |
|
| 55 | * @return $this |
||
| 56 | 8 | */ |
|
| 57 | public function withoutEncodeLabels(bool $value = false): self |
||
| 58 | { |
||
| 59 | $new = clone $this; |
||
| 60 | $new->encodeLabels = $value; |
||
| 61 | |||
| 62 | return $new; |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | 8 | * The button label |
|
| 67 | * |
||
| 68 | 8 | * @param string $value |
|
| 69 | * |
||
| 70 | 8 | * @return $this |
|
| 71 | */ |
||
| 72 | public function withLabel(string $value): self |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * The HTML attributes for the widget container tag. The following special options are recognized. |
||
| 82 | 8 | * |
|
| 83 | * {@see Html::renderTagAttributes()} for details on how attributes are being rendered. |
||
| 84 | 8 | * |
|
| 85 | * @param array $value |
||
| 86 | 8 | * |
|
| 87 | * @return $this |
||
| 88 | */ |
||
| 89 | public function withOptions(array $value): self |
||
| 90 | { |
||
| 91 | $new = clone $this; |
||
| 92 | $new->options = $value; |
||
| 93 | |||
| 94 | return $new; |
||
| 95 | } |
||
| 96 | 3 | ||
| 97 | /** |
||
| 98 | 3 | * The tag to use to render the button. |
|
| 99 | * |
||
| 100 | 3 | * @param string $value |
|
| 101 | * |
||
| 102 | * @return $this |
||
| 103 | */ |
||
| 104 | public function withTagName(string $value): self |
||
| 110 | } |
||
| 111 | |||
| 112 | /** |
||
| 113 | * Allows you to enable or disable the encoding tags html. |
||
| 114 | * |
||
| 115 | * @param bool $value |
||
| 116 | * |
||
| 117 | * @return self |
||
| 118 | */ |
||
| 119 | public function withEncodeTags(bool $value = true): self |
||
| 125 | } |
||
| 126 | } |
||
| 127 |