| Total Complexity | 6 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | abstract class Widget extends \Yiisoft\Widget\Widget |
||
| 8 | { |
||
| 9 | private ?string $id = null; |
||
| 10 | private bool $autoGenerate = true; |
||
| 11 | private string $autoIdPrefix = 'w'; |
||
| 12 | private static int $counter = 0; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Returns the Id of the widget. |
||
| 16 | * |
||
| 17 | * @return string|null Id of the widget. |
||
| 18 | */ |
||
| 19 | 134 | protected function getId(): ?string |
|
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Set the Id of the widget. |
||
| 30 | * |
||
| 31 | * @param string $value |
||
| 32 | * |
||
| 33 | * @return $this |
||
| 34 | */ |
||
| 35 | 1 | public function id(string $value): self |
|
| 36 | { |
||
| 37 | 1 | $new = clone $this; |
|
| 38 | 1 | $new->id = $value; |
|
| 39 | |||
| 40 | 1 | return $new; |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Counter used to generate {@see id} for widgets. |
||
| 45 | * |
||
| 46 | * @param int $value |
||
| 47 | */ |
||
| 48 | 124 | public static function counter(int $value): void |
|
| 51 | 124 | } |
|
| 52 | |||
| 53 | /** |
||
| 54 | * The prefix to the automatically generated widget IDs. |
||
| 55 | * |
||
| 56 | * @param string $value |
||
| 57 | * |
||
| 58 | * @return $this |
||
| 59 | * |
||
| 60 | * {@see getId()} |
||
| 61 | */ |
||
| 62 | 1 | public function autoIdPrefix(string $value): self |
|
| 70 |