File tree Expand file tree Collapse file tree 6 files changed +91
-10
lines changed Expand file tree Collapse file tree 6 files changed +91
-10
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /***************************************************************************
3
+ * Copyright (C) 2011 by Alexey S. Denisov *
4
+ * *
5
+ * This program is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU Lesser General Public License as *
7
+ * published by the Free Software Foundation; either version 3 of the *
8
+ * License, or (at your option) any later version. *
9
+ * *
10
+ ***************************************************************************/
11
+
12
+ /**
13
+ * @ingroup Filters
14
+ **/
15
+ final class CallbackFilter implements Filtrator
16
+ {
17
+ /**
18
+ * @var Closure
19
+ */
20
+ private $ callback = null ;
21
+
22
+ /**
23
+ * @return CallbackFilter
24
+ **/
25
+ public static function create (Closure $ callback )
26
+ {
27
+ return new self ($ callback );
28
+ }
29
+
30
+ public function __construct (Closure $ callback )
31
+ {
32
+ $ this ->callback = $ callback ;
33
+ }
34
+
35
+ public function apply ($ value )
36
+ {
37
+ return $ this ->callback ->__invoke ($ value );
38
+ }
39
+ }
40
+ ?>
Original file line number Diff line number Diff line change 2
2
3
3
* main/Crypto/Base62Utils.class.php: assert check in decode() added.
4
4
5
+ 2011-06-01 Alexey S. Denisov
6
+
7
+ * core/Form/Filters/CallbackFilter.class.php: implemented CallbackFilter
8
+ to work with anonymous functions.
9
+
5
10
2011-06-01 Sergey S. Sergeev
6
11
7
12
* main/Crypto/Base62Utils.class.php: Base62 encode/decode implemented.
Original file line number Diff line number Diff line change 8
8
* License, or (at your option) any later version. *
9
9
* *
10
10
***************************************************************************/
11
-
12
- /**
13
- * @ingroup Exceptions
14
- **/
15
- class MailException extends BaseException {/*_*/ };
16
-
17
- /**
18
- * @ingroup Exceptions
19
- **/
20
- class MailNotSentException extends MailException {/*_*/ };
21
11
22
12
/**
23
13
* @ingroup Mail
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /***************************************************************************
3
+ * Copyright (C) 2004-2007 by Anton E. Lebedevich *
4
+ * *
5
+ * This program is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU Lesser General Public License as *
7
+ * published by the Free Software Foundation; either version 3 of the *
8
+ * License, or (at your option) any later version. *
9
+ * *
10
+ ***************************************************************************/
11
+
12
+ /**
13
+ * @ingroup Exceptions
14
+ **/
15
+ class MailException extends BaseException {/*_*/ };
16
+ ?>
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /***************************************************************************
3
+ * Copyright (C) 2004-2007 by Anton E. Lebedevich *
4
+ * *
5
+ * This program is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU Lesser General Public License as *
7
+ * published by the Free Software Foundation; either version 3 of the *
8
+ * License, or (at your option) any later version. *
9
+ * *
10
+ ***************************************************************************/
11
+
12
+ /**
13
+ * @ingroup Exceptions
14
+ **/
15
+ class MailNotSentException extends MailException {/*_*/ };
16
+ ?>
Original file line number Diff line number Diff line change @@ -228,5 +228,19 @@ public function testUtf16ConverterFilter()
228
228
Utf16ConverterFilter::me ()->apply ('привет ' )
229
229
);
230
230
}
231
+
232
+ public function testCallbackFilter ()
233
+ {
234
+ //simple test
235
+ $ postApply = ' and my applying ' ;
236
+ $ filter = CallbackFilter::create (function ($ value ) use ($ postApply ) {
237
+ return $ value . $ postApply ;
238
+ });
239
+
240
+ $ this ->assertEquals (
241
+ 'one another value and my applying ' ,
242
+ $ filter ->apply ('one another value ' )
243
+ );
244
+ }
231
245
}
232
246
?>
You can’t perform that action at this time.
0 commit comments