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 | 148 | 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 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 | 4 | 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 returns an value in a specific encoding format |
||
93 | * |
||
94 | * @param string|null $toEncodingFormat |
||
95 | * @param string|null $fromEncodingFormat |
||
96 | * @return FilterResource |
||
97 | */ |
||
98 | 5 | public function encode($toEncodingFormat = null, $fromEncodingFormat = null) |
|
102 | |||
103 | /** |
||
104 | * Returns rule that results a casted float |
||
105 | * |
||
106 | * @return $this |
||
107 | */ |
||
108 | 12 | public function float() |
|
112 | |||
113 | /** |
||
114 | * Returns rule that results a casted int |
||
115 | * |
||
116 | * @return $this |
||
117 | */ |
||
118 | 11 | public function int() |
|
122 | |||
123 | /** |
||
124 | * Returns rule that results all letters of a value |
||
125 | * |
||
126 | * @return $this |
||
127 | */ |
||
128 | 3 | public function letters() |
|
132 | |||
133 | /** |
||
134 | * Returns rule that results a lower-cased value |
||
135 | * |
||
136 | * @return $this |
||
137 | */ |
||
138 | 16 | public function lower() |
|
142 | |||
143 | /** |
||
144 | * Returns rule that formats numbers |
||
145 | * |
||
146 | * @param int $decimals |
||
147 | * @param string $decimalPoint |
||
148 | * @param string $thousandSeparator |
||
149 | * @return $this |
||
150 | */ |
||
151 | 12 | public function numberFormat($decimals, $decimalPoint, $thousandSeparator) |
|
152 | { |
||
153 | 12 | return $this->addRule(new FilterRule\NumberFormat($decimals, $decimalPoint, $thousandSeparator)); |
|
154 | } |
||
155 | |||
156 | /** |
||
157 | * Returns rule that results all numbers of a value |
||
158 | * |
||
159 | * @return $this |
||
160 | */ |
||
161 | 3 | public function numbers() |
|
165 | |||
166 | /** |
||
167 | * Results rule that returns the value prepended with a given value |
||
168 | * |
||
169 | * @param string $prepend |
||
170 | * @return Chain |
||
171 | */ |
||
172 | 4 | public function prepend($prepend) |
|
176 | |||
177 | /** |
||
178 | * Results rule that returns a value with replacements by a regex |
||
179 | * |
||
180 | * @param string $searchRegex |
||
181 | * @param string $replace |
||
182 | * @return $this |
||
183 | */ |
||
184 | 2 | public function regexReplace($searchRegex, $replace) |
|
188 | |||
189 | /** |
||
190 | * Results rule that returns a value with replacements |
||
191 | * |
||
192 | * @param mixed $search |
||
193 | * @param mixed $replace |
||
194 | * @return $this |
||
195 | */ |
||
196 | 5 | public function replace($search, $replace) |
|
200 | |||
201 | /** |
||
202 | * Returns rule that results a casted string |
||
203 | * |
||
204 | * @return $this |
||
205 | */ |
||
206 | 7 | public function string() |
|
210 | |||
211 | /** |
||
212 | * Results rule that results a html-stripped value |
||
213 | * |
||
214 | * @param null|string $excludeTags |
||
215 | * @return $this |
||
216 | */ |
||
217 | 4 | public function stripHtml($excludeTags = null) |
|
221 | |||
222 | /** |
||
223 | * Returns rule that results a trimmed value |
||
224 | * |
||
225 | * @param string|null $characters |
||
226 | * @return $this |
||
227 | */ |
||
228 | 21 | public function trim($characters = null) |
|
232 | |||
233 | /** |
||
234 | * Results rule that returns an upper-cased value |
||
235 | * |
||
236 | * @return $this |
||
237 | */ |
||
238 | 6 | public function upper() |
|
242 | |||
243 | /** |
||
244 | * Returns rule that results a value starting with a upper-cased character |
||
245 | * |
||
246 | * @return $this |
||
247 | */ |
||
248 | 14 | public function upperFirst() |
|
252 | |||
253 | /** |
||
254 | * Add a new rule to the chain |
||
255 | * |
||
256 | * @param FilterRule $rule |
||
257 | * @return $this |
||
258 | */ |
||
259 | 147 | protected function addRule(FilterRule $rule) |
|
275 | } |
||
276 |