1 | <?php |
||
9 | class CheckboxGroup |
||
10 | { |
||
11 | use OutputImporter, ParserImporter, UtilImporter; |
||
12 | |||
13 | protected $checkboxes = []; |
||
14 | |||
15 | protected $count; |
||
16 | |||
17 | 16 | public function __construct(array $options) |
|
28 | |||
29 | 16 | public function write() |
|
33 | |||
34 | /** |
||
35 | * Retrieve the checked option values |
||
36 | * |
||
37 | * @return array |
||
38 | */ |
||
39 | 12 | public function getCheckedValues() |
|
43 | |||
44 | /** |
||
45 | * Set the newly selected option based on the direction |
||
46 | * |
||
47 | * @param string $direction 'previous' or 'next' |
||
48 | */ |
||
49 | 8 | public function setCurrent($direction) |
|
59 | |||
60 | /** |
||
61 | * Toggle the current option's checked status |
||
62 | */ |
||
63 | 12 | public function toggleCurrent() |
|
69 | |||
70 | /** |
||
71 | * Get the number of checkboxes |
||
72 | * |
||
73 | * @return int |
||
74 | */ |
||
75 | 16 | public function count() |
|
79 | |||
80 | /** |
||
81 | * Retrieve the checked options |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | 16 | protected function getChecked() |
|
89 | |||
90 | /** |
||
91 | * Determine whether the option is checked |
||
92 | * |
||
93 | * @param Checkbox $option |
||
94 | * |
||
95 | * @return bool |
||
96 | */ |
||
97 | 16 | protected function isChecked($option) |
|
101 | |||
102 | /** |
||
103 | * Retrieve the option's value |
||
104 | * |
||
105 | * @param Checkbox $option |
||
106 | * |
||
107 | * @return mixed |
||
108 | */ |
||
109 | 8 | protected function getValue($option) |
|
113 | |||
114 | /** |
||
115 | * Get the currently selected option |
||
116 | * |
||
117 | * @return array |
||
118 | */ |
||
119 | 16 | protected function getCurrent() |
|
127 | |||
128 | /** |
||
129 | * Retrieve the correct current key |
||
130 | * |
||
131 | * @param string $direction 'previous' or 'next' |
||
132 | * @param Checkbox $option |
||
133 | * @param int $key |
||
134 | * |
||
135 | * @return int |
||
136 | */ |
||
137 | 8 | protected function getCurrentKey($direction, $option, $key) |
|
143 | |||
144 | /** |
||
145 | * @param Checkbox $option |
||
146 | * @param int $key |
||
147 | * |
||
148 | * @return int |
||
149 | */ |
||
150 | protected function getPreviousKey($option, $key) |
||
158 | |||
159 | /** |
||
160 | * @param Checkbox $option |
||
161 | * @param int $key |
||
162 | * |
||
163 | * @return int |
||
164 | */ |
||
165 | 8 | protected function getNextKey($option, $key) |
|
173 | |||
174 | /** |
||
175 | * @param Checkbox $checkbox |
||
176 | */ |
||
177 | 16 | protected function writeCheckbox($checkbox) |
|
191 | } |
||
192 |