summaryrefslogtreecommitdiff
path: root/www/wiki/vendor/param-processor/param-processor/src/IParamDefinition.php
blob: 410b8096bd88bf604cc5b7c339efd79e0e31a8c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<?php

namespace ParamProcessor;

use ValueParsers\ValueParser;
use ValueValidators\ValueValidator;

/**
 * Interface for parameter definition classes.
 *
 * @since 1.0
 * @deprecated since 1.0, use ParamDefinition
 *
 * @licence GNU GPL v2+
 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 */
interface IParamDefinition {

	/**
	 * Adds one or more aliases for the parameter name.
	 *
	 * @since 1.0
	 *
	 * @param string|string[] $aliases
	 */
	public function addAliases( $aliases );

	/**
	 * Adds one or more dependencies. There are the names of parameters
	 * that need to be validated and formatted before this one.
	 *
	 * @since 1.0
	 *
	 * @param string|string[] $dependencies
	 */
	public function addDependencies( $dependencies );

	/**
	 * Formats the parameter value to it's final result.
	 *
	 * @since 1.0
	 *
	 * @param $param IParam
	 * @param $definitions array of IParamDefinition
	 * @param $params array of IParam
	 */
	public function format( IParam $param, array &$definitions, array $params );

	/**
	 * Returns the parameter name aliases.
	 *
	 * @since 1.0
	 *
	 * @return string[]
	 */
	public function getAliases(): array;

	/**
	 * Returns the default value.
	 *
	 * @since 1.0
	 *
	 * @return mixed
	 */
	public function getDefault();

	/**
	 * Returns the delimiter to use to split the raw value in case the
	 * parameter is a list.
	 *
	 * @since 1.0
	 *
	 * @return string
	 */
	public function getDelimiter(): string;

	/**
	 * Returns a list of dependencies the parameter has, in the form of
	 * other parameter names.
	 *
	 * @since 1.0
	 *
	 * @return string[]
	 */
	public function getDependencies(): array;

	/**
	 * Returns a message that will act as a description message for the parameter.
	 *
	 * @since 1.0
	 *
	 * @return string
	 */
	public function getMessage(): string;

	/**
	 * Returns the parameters main name.
	 *
	 * @since 1.0
	 *
	 * @return string
	 */
	public function getName(): string;

	/**
	 * Returns an identifier for the type of the parameter.
	 *
	 * @since 1.0
	 *
	 * @return string
	 */
	public function getType(): string;

	/**
	 * Returns if the parameter has a certain alias.
	 *
	 * @since 1.0
	 *
	 * @param string $alias
	 *
	 * @return boolean
	 */
	public function hasAlias( string $alias ): bool;

	/**
	 * Returns if the parameter has a certain dependency.
	 *
	 * @since 1.0
	 *
	 * @param string $dependency
	 *
	 * @return boolean
	 */
	public function hasDependency( string $dependency ): bool;

	/**
	 * Returns if the parameter is a list or not.
	 *
	 * @since 1.0
	 *
	 * @return boolean
	 */
	public function isList(): bool;

	/**
	 * Returns if the parameter is a required one or not.
	 *
	 * @since 1.0
	 *
	 * @return boolean
	 */
	public function isRequired(): bool;

	/**
	 * Sets the default parameter value. Null indicates no default,
	 * and therefore makes the parameter required.
	 *
	 * @since 1.0
	 *
	 * @param mixed $default
	 * @param boolean $manipulate Should the default be manipulated or not? Since 0.4.6.
	 */
	public function setDefault( $default, $manipulate = true );

	/**
	 * Sets the delimiter to use to split the raw value in case the
	 * parameter is a list.
	 *
	 * @since 1.0
	 *
	 * @param $delimiter string
	 */
	public function setDelimiter( string $delimiter );

	/**
	 * Set if the parameter manipulations should be applied to the default value.
	 *
	 * @since 1.0
	 *
	 * @param boolean $manipulateDefault
	 */
	public function setDoManipulationOfDefault( bool $manipulateDefault );

	/**
	 * Sets a message for the parameter that will act as description.
	 *
	 *
	 * @since 1.0
	 *
	 * @param string $message
	 */
	public function setMessage( string $message );

	/**
	 * Returns if the parameter manipulations should be applied to the default value.
	 *
	 * @since 1.0
	 *
	 * @return boolean
	 */
	public function shouldManipulateDefault(): bool;

	/**
	 * Returns a message key for a message describing the parameter type.
	 *
	 * @since 1.0
	 *
	 * @return string
	 */
	public function getTypeMessage(): string;

	/**
	 * Returns if the value should be trimmed before validation and any further processing.
	 *
	 * @since 1.0
	 *
	 * @since boolean|null
	 */
	public function trimDuringClean();

	/**
	 * Returns a ValueParser object to parse the parameters value.
	 *
	 * @since 1.0
	 *
	 * @return ValueParser
	 */
	public function getValueParser();

	/**
	 * Returns the ValueParser object to parse the parameters value.
	 *
	 * @since 1.0
	 *
	 * @param ValueParser $parser
	 */
	public function setValueParser( ValueParser $parser );

	/**
	 * Returns a ValueValidator that can be used to validate the parameters value.
	 *
	 * @since 1.0
	 *
	 * @return ValueValidator
	 */
	public function getValueValidator();

	/**
	 * Sets the ValueValidator that can be used to validate the parameters value.
	 *
	 * @since 1.0
	 *
	 * @param ValueValidator $validator
	 */
	public function setValueValidator( ValueValidator $validator );

	/**
	 * Sets a validation function that will be run before the ValueValidator.
	 *
	 * This can be used instead of a ValueValidator where validation is very
	 * trivial, ie checking if something is a boolean can be done with is_bool.
	 *
	 * @since 1.0
	 *
	 * @param callable $validationFunction
	 */
	public function setValidationCallback( callable $validationFunction );

	/**
	 * Sets the parameter definition values contained in the provided array.
	 *
	 * @since 1.0
	 *
	 * @param array $options
	 */
	public function setArrayValues( array $options );

	/**
	 * Returns a validation function that should be run before the ValueValidator.
	 *
	 * @since 1.0
	 *
	 * @return callable|null
	 */
	public function getValidationCallback();

}