Total Complexity | 5 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class CheckableItem implements MenuItemInterface, ToggableItemInterface, CheckableInterface |
||
9 | { |
||
10 | use ToggableTrait; |
||
11 | |||
12 | public function __construct( |
||
13 | string $text, |
||
14 | callable $selectAction, |
||
15 | bool $showItemExtra = false, |
||
16 | bool $disabled = false |
||
17 | ) { |
||
18 | $this->text = $text; |
||
19 | $this->selectAction = $selectAction; |
||
20 | $this->showItemExtra = $showItemExtra; |
||
21 | $this->disabled = $disabled; |
||
22 | } |
||
23 | |||
24 | public function getStyle() : Style\ItemStyleInterface |
||
25 | { |
||
26 | if (!$this->style) { |
||
27 | $this->style = new Style\CheckableStyle(); |
||
28 | } |
||
29 | |||
30 | return $this->style; |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @param Style\CheckableStyle|Style\ItemStyleInterface $style |
||
35 | * @return $this |
||
36 | */ |
||
37 | public function setStyle(Style\ItemStyleInterface $style) : self |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Execute the items callable if required |
||
46 | */ |
||
47 | public function getSelectAction() : ?callable |
||
54 | }; |
||
55 | } |
||
57 |