File tree Expand file tree Collapse file tree 4 files changed +17
-16
lines changed Expand file tree Collapse file tree 4 files changed +17
-16
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- package TgUtils;
3
+ namespace TgUtils ;
4
4
5
5
/**
6
6
* An interface for not filtering string at all.
7
7
*/
8
- public class DummyStringFilter implements StringFilter {
8
+ class DummyStringFilter implements StringFilter {
9
9
10
- public static $ INSTANCE = new DummyStringFilter () ;
10
+ public static $ INSTANCE ;
11
11
12
- public __construct() {
12
+ public function __construct () {
13
13
}
14
14
15
15
/**
16
16
* Filters the given string and returns sanitized value.
17
17
* @param string $s - string to sanitize (can be null)
18
18
* @return the sanitized string.
19
19
*/
20
- public filter ($ s ) {
20
+ public function filter ($ s ) {
21
21
return $ s ;
22
22
}
23
23
24
24
}
25
-
25
+ DummyStringFilter:: $ INSTANCE = new DummyStringFilter ();
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- package TgUtils;
3
+ namespace TgUtils ;
4
4
5
5
/**
6
6
* An interface for filter strings from any HTML tags.
7
7
*/
8
- public class NoHtmlStringFilter implements StringFilter {
8
+ class NoHtmlStringFilter implements StringFilter {
9
9
10
- public static $ INSTANCE = new NoHtmlStringFilter () ;
10
+ public static $ INSTANCE ;
11
11
12
- public __construct() {
12
+ public function __construct () {
13
13
}
14
14
15
15
/**
16
16
* Filters the given string and returns sanitized value.
17
17
* @param string $s - string to sanitize (can be null)
18
18
* @return the sanitized string.
19
19
*/
20
- public filter ($ s ) {
20
+ public function filter ($ s ) {
21
21
if ($ s == NULL ) return $ s ;
22
22
return strip_tags ($ s );
23
23
}
24
24
25
25
}
26
+ NoHtmlStringFilter::$ INSTANCE = new NoHtmlStringFilter ();
26
27
Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ public function hasGetParam($key) {
193
193
*/
194
194
public function getGetParam ($ key , $ default = NULL , $ filter = NULL ) {
195
195
$ params = $ this ->getParams ;
196
- if ($ filter == NULL ) $ filter = StringFilters ::$ NO_HTML ;
196
+ if ($ filter == NULL ) $ filter = NoHtmlStringFilter ::$ INSTANCE ;
197
197
return isset ($ params [$ key ]) ? $ filter ->filter ($ params [$ key ]) : $ default ;
198
198
}
199
199
@@ -223,7 +223,7 @@ public function hasPostParam($key) {
223
223
*/
224
224
public function getPostParam ($ key , $ default = NULL , $ filter = NULL ) {
225
225
$ params = $ this ->getPostParams ();
226
- if ($ filter == NULL ) $ filter = StringFilters ::$ NO_HTML ;
226
+ if ($ filter == NULL ) $ filter = NoHtmlStringFilter ::$ INSTANCE ;
227
227
return isset ($ params [$ key ]) ? $ filter ->filter ($ params [$ key ]) : $ default ;
228
228
}
229
229
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- package TgUtils;
3
+ namespace TgUtils ;
4
4
5
5
/**
6
6
* An interface for filter strings from evil input.
7
7
*/
8
- public interface StringFilter {
8
+ interface StringFilter {
9
9
10
10
/**
11
11
* Filters the given string and returns sanitized value.
12
12
* @param string $s - string to sanitize (can be null)
13
13
* @return the sanitized string.
14
14
*/
15
- public filter ($ s );
15
+ public function filter ($ s );
16
16
17
17
}
18
18
You can’t perform that action at this time.
0 commit comments