| Total Complexity | 7 |
| Total Lines | 80 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | class Button extends Widget |
||
| 21 | { |
||
| 22 | private string $tagName = 'button'; |
||
| 23 | private string $label = 'Button'; |
||
| 24 | private bool $encodeLabels = true; |
||
| 25 | private array $options = []; |
||
| 26 | |||
| 27 | 9 | protected function run(): string |
|
| 41 | ); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Whether the label should be HTML-encoded. |
||
| 46 | * |
||
| 47 | * @param bool $value |
||
| 48 | * |
||
| 49 | * @return $this |
||
| 50 | */ |
||
| 51 | 9 | public function encodeLabels(bool $value): self |
|
| 52 | { |
||
| 53 | 9 | $this->encodeLabels = $value; |
|
| 54 | |||
| 55 | 9 | return $this; |
|
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * The button label |
||
| 60 | * |
||
| 61 | * @param string $value |
||
| 62 | * |
||
| 63 | * @return $this |
||
| 64 | */ |
||
| 65 | 9 | public function label(string $value): self |
|
| 66 | { |
||
| 67 | 9 | $this->label = $value; |
|
| 68 | |||
| 69 | 9 | return $this; |
|
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * The HTML attributes for the widget container tag. The following special options are recognized. |
||
| 74 | * |
||
| 75 | * {@see \Yiisoft\Html\Html::renderTagAttributes()} for details on how attributes are being rendered. |
||
| 76 | * |
||
| 77 | * @param array $value |
||
| 78 | * |
||
| 79 | * @return $this |
||
| 80 | */ |
||
| 81 | 9 | public function options(array $value): self |
|
| 82 | { |
||
| 83 | 9 | $this->options = $value; |
|
| 84 | |||
| 85 | 9 | return $this; |
|
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * The tag to use to render the button. |
||
| 90 | * |
||
| 91 | * @param string $value |
||
| 92 | * |
||
| 93 | * @return $this |
||
| 94 | */ |
||
| 95 | 3 | public function tagName(string $value): self |
|
| 100 | } |
||
| 101 | } |
||
| 102 |