Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Form\Element; |
15 | |
16 | /** |
17 | * Form element interface |
18 | * |
19 | * @category Pop |
20 | * @package Pop\Form |
21 | * @author Nick Sagona, III <dev@nolainteractive.com> |
22 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
23 | * @license http://www.popphp.org/license New BSD License |
24 | * @version 4.0.0 |
25 | */ |
26 | interface ElementInterface |
27 | { |
28 | |
29 | /** |
30 | * Set the name of the form element |
31 | * |
32 | * @param string $name |
33 | * @return ElementInterface |
34 | */ |
35 | public function setName(string $name): ElementInterface; |
36 | |
37 | /** |
38 | * Set the value of the form element |
39 | * |
40 | * @param mixed $value |
41 | * @return ElementInterface |
42 | */ |
43 | public function setValue(mixed $value): ElementInterface; |
44 | |
45 | /** |
46 | * Reset the value of the form element |
47 | * |
48 | * @return ElementInterface |
49 | */ |
50 | public function resetValue(): ElementInterface; |
51 | |
52 | /** |
53 | * Set the label of the form element |
54 | * |
55 | * @param string $label |
56 | * @return ElementInterface |
57 | */ |
58 | public function setLabel(string $label): ElementInterface; |
59 | |
60 | /** |
61 | * Set the attributes of the label of the form element |
62 | * |
63 | * @param array $attribs |
64 | * @return ElementInterface |
65 | */ |
66 | public function setLabelAttributes(array $attribs): ElementInterface; |
67 | |
68 | /** |
69 | * Set whether the form element is required |
70 | * |
71 | * @param bool $required |
72 | * @return mixed |
73 | */ |
74 | public function setRequired(bool $required): mixed; |
75 | |
76 | /** |
77 | * Set whether the form element is disabled |
78 | * |
79 | * @param bool $disabled |
80 | * @return mixed |
81 | */ |
82 | public function setDisabled(bool $disabled): mixed; |
83 | |
84 | /** |
85 | * Set whether the form element is readonly |
86 | * |
87 | * @param bool $readonly |
88 | * @return mixed |
89 | */ |
90 | public function setReadonly(bool $readonly): mixed; |
91 | |
92 | /** |
93 | * Set error to display before the element |
94 | * |
95 | * @param bool $pre |
96 | * @return ElementInterface |
97 | */ |
98 | public function setErrorPre(bool $pre): ElementInterface; |
99 | |
100 | /** |
101 | * Determine if error to display before the element |
102 | * |
103 | * @return bool |
104 | */ |
105 | public function isErrorPre(): bool; |
106 | |
107 | /** |
108 | * Set validators |
109 | * |
110 | * @param array $validators |
111 | * @return ElementInterface |
112 | */ |
113 | public function setValidators(array $validators = []): ElementInterface; |
114 | |
115 | /** |
116 | * Clear errors |
117 | * |
118 | * @return ElementInterface |
119 | */ |
120 | public function clearErrors(): ElementInterface; |
121 | |
122 | /** |
123 | * Get form element name |
124 | * |
125 | * @return ?string |
126 | */ |
127 | public function getName(): ?string; |
128 | |
129 | /** |
130 | * Get form element object type |
131 | * |
132 | * @return ?string |
133 | */ |
134 | public function getType(): ?string; |
135 | |
136 | /** |
137 | * Get form element value |
138 | * |
139 | * @return mixed |
140 | */ |
141 | public function getValue(): mixed; |
142 | |
143 | /** |
144 | * Get form element label |
145 | * |
146 | * @return ?string |
147 | */ |
148 | public function getLabel(): ?string; |
149 | |
150 | /** |
151 | * Get the attributes of the form element label |
152 | * |
153 | * @return array |
154 | */ |
155 | public function getLabelAttributes(): array; |
156 | |
157 | /** |
158 | * Get validators |
159 | * |
160 | * @return array |
161 | */ |
162 | public function getValidators(): array; |
163 | |
164 | /** |
165 | * Get whether the form element is required |
166 | * |
167 | * @return bool |
168 | */ |
169 | public function isRequired(): bool; |
170 | |
171 | /** |
172 | * Get whether the form element is disabled |
173 | * |
174 | * @return bool |
175 | */ |
176 | public function isDisabled(): bool; |
177 | |
178 | /** |
179 | * Get whether the form element is readonly |
180 | * |
181 | * @return bool |
182 | */ |
183 | public function isReadonly(): bool; |
184 | |
185 | /** |
186 | * Get whether the form element object is a button |
187 | * |
188 | * @return bool |
189 | */ |
190 | public function isButton(): bool; |
191 | |
192 | /** |
193 | * Get form element errors |
194 | * |
195 | * @return array |
196 | */ |
197 | public function getErrors(): array; |
198 | |
199 | /** |
200 | * Get if form element has errors |
201 | * |
202 | * @return bool |
203 | */ |
204 | public function hasErrors(): bool; |
205 | |
206 | /** |
207 | * Add a validator the form element |
208 | * |
209 | * @param mixed $validator |
210 | * @return ElementInterface |
211 | */ |
212 | public function addValidator(mixed $validator): ElementInterface; |
213 | |
214 | /** |
215 | * Validate the value |
216 | * |
217 | * @param mixed $value |
218 | * @param array $formValues |
219 | * @return void |
220 | */ |
221 | public function validateValue(mixed $value, array $formValues = []): void; |
222 | |
223 | /** |
224 | * Validate the value by callable |
225 | * |
226 | * @param callable $validator |
227 | * @param mixed $value |
228 | * @param array $formValues |
229 | * @return void |
230 | */ |
231 | public function validateCallable(callable $validator, mixed $value, array $formValues = []): void; |
232 | |
233 | /** |
234 | * Validate the form element |
235 | * |
236 | * @param array $formValues |
237 | * @return bool |
238 | */ |
239 | public function validate(array $formValues = []): bool; |
240 | |
241 | } |