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 | 152 | public function __construct(Filter $filter, $keys = null) |
|
32 | { |
||
33 | 152 | $this->filter = $filter; |
|
34 | 152 | $this->keys = $keys; |
|
35 | 152 | } |
|
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 Chain |
||
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 | * Returns rule that defaults a given value if the data key was not provided |
||
82 | * |
||
83 | * @param mixed $defaultValue |
||
84 | * @return $this |
||
85 | */ |
||
86 | 13 | public function defaults($defaultValue) |
|
90 | |||
91 | /** |
||
92 | * Returns rule that can filter repeated nested arrays |
||
93 | * |
||
94 | * @param callable $callable |
||
95 | * @return $this |
||
96 | */ |
||
97 | 2 | public function each(callable $callable) |
|
101 | |||
102 | /** |
||
103 | * Returns rule that returns an value in a specific encoding format |
||
104 | * |
||
105 | * @param string|null $toEncodingFormat |
||
106 | * @param string|null $fromEncodingFormat |
||
107 | * @return $this |
||
108 | */ |
||
109 | 5 | public function encode($toEncodingFormat = null, $fromEncodingFormat = null) |
|
113 | |||
114 | /** |
||
115 | * Returns rule that results a casted float |
||
116 | * |
||
117 | * @return $this |
||
118 | */ |
||
119 | 12 | public function float() |
|
123 | |||
124 | /** |
||
125 | * Returns rule that results a casted int |
||
126 | * |
||
127 | * @return $this |
||
128 | */ |
||
129 | 11 | public function int() |
|
133 | |||
134 | /** |
||
135 | * Returns rule that results all letters of a value |
||
136 | * |
||
137 | * @return $this |
||
138 | */ |
||
139 | 3 | public function letters() |
|
143 | |||
144 | /** |
||
145 | * Returns rule that results a lower-cased value |
||
146 | * |
||
147 | * @return $this |
||
148 | */ |
||
149 | 17 | public function lower() |
|
153 | |||
154 | /** |
||
155 | * Returns rule that formats numbers |
||
156 | * |
||
157 | * @param int $decimals |
||
158 | * @param string $decimalPoint |
||
159 | * @param string $thousandSeparator |
||
160 | * @return $this |
||
161 | */ |
||
162 | 12 | public function numberFormat($decimals, $decimalPoint, $thousandSeparator) |
|
166 | |||
167 | /** |
||
168 | * Returns rule that results all numbers of a value |
||
169 | * |
||
170 | * @return $this |
||
171 | */ |
||
172 | 3 | public function numbers() |
|
176 | |||
177 | /** |
||
178 | * Results rule that returns the value prepended with a given value |
||
179 | * |
||
180 | * @param string $prepend |
||
181 | * @return Chain |
||
182 | */ |
||
183 | 4 | public function prepend($prepend) |
|
187 | |||
188 | /** |
||
189 | * Results rule that returns a value with replacements by a regex |
||
190 | * |
||
191 | * @param string $searchRegex |
||
192 | * @param string $replace |
||
193 | * @return $this |
||
194 | */ |
||
195 | 2 | public function regexReplace($searchRegex, $replace) |
|
199 | |||
200 | /** |
||
201 | * Results rule that returns a value with replacements |
||
202 | * |
||
203 | * @param mixed $search |
||
204 | * @param mixed $replace |
||
205 | * @return $this |
||
206 | */ |
||
207 | 5 | public function replace($search, $replace) |
|
211 | |||
212 | /** |
||
213 | * Returns rule that results a casted string |
||
214 | * |
||
215 | * @return $this |
||
216 | */ |
||
217 | 7 | public function string() |
|
221 | |||
222 | /** |
||
223 | * Results rule that results a html-stripped value |
||
224 | * |
||
225 | * @param null|string $excludeTags |
||
226 | * @return $this |
||
227 | */ |
||
228 | 4 | public function stripHtml($excludeTags = null) |
|
232 | |||
233 | /** |
||
234 | * Returns rule that results a trimmed value |
||
235 | * |
||
236 | * @param string|null $characters |
||
237 | * @return $this |
||
238 | */ |
||
239 | 21 | public function trim($characters = null) |
|
243 | |||
244 | /** |
||
245 | * Results rule that returns an upper-cased value |
||
246 | * |
||
247 | * @return $this |
||
248 | */ |
||
249 | 7 | public function upper() |
|
253 | |||
254 | /** |
||
255 | * Returns rule that results a value starting with a upper-cased character |
||
256 | * |
||
257 | * @return $this |
||
258 | */ |
||
259 | 14 | public function upperFirst() |
|
263 | |||
264 | /** |
||
265 | * Add a new rule to the chain |
||
266 | * |
||
267 | * @param FilterRule $rule |
||
268 | * @return $this |
||
269 | */ |
||
270 | 151 | protected function addRule(FilterRule $rule) |
|
286 | } |
||
287 |