Total Complexity | 10 |
Total Lines | 90 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | trait ToggableTrait |
||
6 | { |
||
7 | /** |
||
8 | * @var callable |
||
9 | */ |
||
10 | private $selectAction; |
||
11 | |||
12 | private $text = ''; |
||
13 | |||
14 | private $showItemExtra = false; |
||
15 | |||
16 | private $disabled = false; |
||
17 | |||
18 | private $checked = false; |
||
19 | |||
20 | /** |
||
21 | * Toggles checked state |
||
22 | */ |
||
23 | public function toggle() : void |
||
24 | { |
||
25 | $this->checked = !$this->checked; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Sets checked state to true |
||
30 | */ |
||
31 | public function setChecked() : void |
||
32 | { |
||
33 | $this->checked = true; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Sets checked state to false |
||
38 | */ |
||
39 | public function setUnchecked() : void |
||
40 | { |
||
41 | $this->checked = false; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Whether or not the item is checked |
||
46 | */ |
||
47 | public function getChecked() : bool |
||
48 | { |
||
49 | return $this->checked; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Return the raw string of text |
||
54 | */ |
||
55 | public function getText() : string |
||
56 | { |
||
57 | return $this->text; |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Set the raw string of text |
||
62 | */ |
||
63 | public function setText(string $text) : void |
||
64 | { |
||
65 | $this->text = $text; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Can the item be selected |
||
70 | */ |
||
71 | public function canSelect() : bool |
||
74 | } |
||
75 | |||
76 | public function showsItemExtra() : bool |
||
77 | { |
||
78 | return $this->showItemExtra; |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Enable showing item extra |
||
83 | */ |
||
84 | public function showItemExtra() : void |
||
85 | { |
||
86 | $this->showItemExtra = true; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Disable showing item extra |
||
91 | */ |
||
92 | public function hideItemExtra() : void |
||
95 | } |
||
96 | } |
||
97 |