1 | <?php |
||
15 | class FilterResource |
||
16 | { |
||
17 | /** |
||
18 | * @var Filter |
||
19 | */ |
||
20 | protected $filter; |
||
21 | |||
22 | /** |
||
23 | * @var null|string|string[] |
||
24 | */ |
||
25 | protected $keys; |
||
26 | |||
27 | /** |
||
28 | * @param Filter $filter |
||
29 | * @param null|string|string[] $keys |
||
30 | */ |
||
31 | 188 | public function __construct(Filter $filter, $keys = null) |
|
36 | |||
37 | /** |
||
38 | * Results rule that returns alphabetic numeric characters from the value |
||
39 | * |
||
40 | * @return $this |
||
41 | */ |
||
42 | 4 | public function alnum() |
|
46 | |||
47 | /** |
||
48 | * Results rule that returns the value appended with a given value |
||
49 | * |
||
50 | * @param string $append |
||
51 | * @return $this |
||
52 | */ |
||
53 | 4 | public function append($append) |
|
57 | |||
58 | /** |
||
59 | * Results rule that returns a casted boolean |
||
60 | * |
||
61 | * @return $this |
||
62 | */ |
||
63 | 16 | public function bool() |
|
67 | |||
68 | /** |
||
69 | * Returns rule that returns a value modified by a callable closure |
||
70 | * |
||
71 | * @param callable $callable |
||
72 | * @param bool $allowNotSet |
||
73 | * @return $this |
||
74 | */ |
||
75 | 6 | public function callback(callable $callable, $allowNotSet = false) |
|
79 | |||
80 | /** |
||
81 | * Results rule that returns the cut value |
||
82 | * |
||
83 | * @param int $start |
||
84 | * @param int|null $length |
||
85 | * @return $this |
||
86 | */ |
||
87 | 4 | public function cut($start, $length = null) |
|
91 | |||
92 | /** |
||
93 | * Returns rule that decodes JSON code of a given value |
||
94 | * |
||
95 | * @param bool $assoc When `true`, decoded objects will be converted into associative arrays |
||
96 | * @param int $depth Decode recursion dept |
||
97 | * @param int $options Bitmask of JSON decode options |
||
98 | * @see http://php.net/manual/en/function.json-decode.php More information about the parameters |
||
99 | * @return $this |
||
100 | */ |
||
101 | 11 | public function decodeJSON($assoc = true, $depth = 512, $options = 0) |
|
105 | |||
106 | /** |
||
107 | * Returns rule that defaults a given value if the data key was not provided |
||
108 | * |
||
109 | * @param mixed $defaultValue |
||
110 | * @return $this |
||
111 | */ |
||
112 | 13 | public function defaults($defaultValue) |
|
116 | |||
117 | /** |
||
118 | * Returns rule that can filter repeated nested arrays |
||
119 | * |
||
120 | * @param callable $callable |
||
121 | * @return $this |
||
122 | */ |
||
123 | 2 | public function each(callable $callable) |
|
127 | |||
128 | /** |
||
129 | * Returns rule that returns an value in a specific encoding format |
||
130 | * |
||
131 | * @param string|null $toEncodingFormat |
||
132 | * @param string|null $fromEncodingFormat |
||
133 | * @return $this |
||
134 | */ |
||
135 | 5 | public function encode($toEncodingFormat = null, $fromEncodingFormat = null) |
|
139 | |||
140 | /** |
||
141 | * Returns rule that results a casted float |
||
142 | * |
||
143 | * @return $this |
||
144 | */ |
||
145 | 12 | public function float() |
|
149 | |||
150 | /** |
||
151 | * Returns rule that results a casted int |
||
152 | * |
||
153 | * @return $this |
||
154 | */ |
||
155 | 11 | public function int() |
|
159 | |||
160 | /** |
||
161 | * Returns rule that results all letters of a value |
||
162 | * |
||
163 | * @return $this |
||
164 | */ |
||
165 | 3 | public function letters() |
|
169 | |||
170 | /** |
||
171 | * Returns rule that results a lower-cased value |
||
172 | * |
||
173 | * @return $this |
||
174 | */ |
||
175 | 17 | public function lower() |
|
179 | |||
180 | /** |
||
181 | * Returns rule that formats numbers |
||
182 | * |
||
183 | * @param int $decimals |
||
184 | * @param string $decimalPoint |
||
185 | * @param string $thousandSeparator |
||
186 | * @return $this |
||
187 | */ |
||
188 | 12 | public function numberFormat($decimals, $decimalPoint, $thousandSeparator) |
|
192 | |||
193 | /** |
||
194 | * Returns rule that results all numbers of a value |
||
195 | * |
||
196 | * @return $this |
||
197 | */ |
||
198 | 3 | public function numbers() |
|
202 | |||
203 | /** |
||
204 | * Results rule that returns the value prepended with a given value |
||
205 | * |
||
206 | * @param string $prepend |
||
207 | * @return $this |
||
208 | */ |
||
209 | 4 | public function prepend($prepend) |
|
213 | |||
214 | /** |
||
215 | * Results rule that returns a value with replacements by a regex |
||
216 | * |
||
217 | * @param string $searchRegex |
||
218 | * @param string $replace |
||
219 | * @return $this |
||
220 | */ |
||
221 | 2 | public function regexReplace($searchRegex, $replace) |
|
225 | |||
226 | /** |
||
227 | * Results rule that returns an empty result so it can be removed |
||
228 | * |
||
229 | * @return $this |
||
230 | */ |
||
231 | 5 | public function remove() |
|
235 | |||
236 | /** |
||
237 | * Results rule that returns an empty result when the value is null so it can be removed |
||
238 | * |
||
239 | * @return $this |
||
240 | */ |
||
241 | 7 | public function removeNull() |
|
245 | |||
246 | /** |
||
247 | * Results rule that returns a value with replacements |
||
248 | * |
||
249 | * @param mixed $search |
||
250 | * @param mixed $replace |
||
251 | * @return $this |
||
252 | */ |
||
253 | 5 | public function replace($search, $replace) |
|
257 | |||
258 | /** |
||
259 | * Results that returns a value slugged |
||
260 | * |
||
261 | * @param string|null $fieldToSlugFrom |
||
262 | * @return $this |
||
263 | */ |
||
264 | 9 | public function slug($fieldToSlugFrom = null) |
|
268 | |||
269 | /** |
||
270 | * Returns rule that results a casted string |
||
271 | * |
||
272 | * @return $this |
||
273 | */ |
||
274 | 7 | public function string() |
|
278 | |||
279 | /** |
||
280 | * Results rule that results a html-stripped value |
||
281 | * |
||
282 | * @param null|string $excludeTags |
||
283 | * @return $this |
||
284 | */ |
||
285 | 4 | public function stripHtml($excludeTags = null) |
|
289 | |||
290 | /** |
||
291 | * Returns rule that results a trimmed value |
||
292 | * |
||
293 | * @param string|null $characters |
||
294 | * @return $this |
||
295 | */ |
||
296 | 21 | public function trim($characters = null) |
|
300 | |||
301 | /** |
||
302 | * Results rule that returns an upper-cased value |
||
303 | * |
||
304 | * @return $this |
||
305 | */ |
||
306 | 7 | public function upper() |
|
310 | |||
311 | /** |
||
312 | * Returns rule that results a value starting with a upper-cased character |
||
313 | * |
||
314 | * @return $this |
||
315 | */ |
||
316 | 14 | public function upperFirst() |
|
320 | |||
321 | /** |
||
322 | * Add a new rule to the chain |
||
323 | * |
||
324 | * @param FilterRule $rule |
||
325 | * @return $this |
||
326 | */ |
||
327 | 187 | protected function addRule(FilterRule $rule) |
|
343 | } |
||
344 |