Skip to content

Commit 296fc85

Browse files
authored
Fix Typo
1 parent 5a14056 commit 296fc85

File tree

2 files changed

+82
-82
lines changed

2 files changed

+82
-82
lines changed

src/Red/SanitizeService/Rules.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
<?php
2-
/** Red Framework
3-
* Sanitization Rules
4-
* @author RedCoder
5-
* http://redframework.ir
6-
*/
7-
8-
namespace Red\SanitizeService;
9-
10-
11-
class Rules
12-
{
13-
public static function rules()
14-
{
15-
16-
/*
17-
Example:
18-
Sanitize::addRule("test", function ($string) {
19-
// Do Your Sanitize then Return String
20-
});*/
21-
22-
}
23-
1+
<?php
2+
/** Red Framework
3+
* Sanitization Rules
4+
* @author RedCoder
5+
* http://redframework.ir
6+
*/
7+
8+
namespace Red\SanitizeService;
9+
10+
11+
class Rules
12+
{
13+
public static function rules()
14+
{
15+
16+
/*
17+
Example:
18+
Sanitize::addRule("test", function ($string) {
19+
// Do Your Sanitize then Return String
20+
});*/
21+
22+
}
23+
2424
}
Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,60 @@
1-
<?php
2-
/** Red Framework
3-
* Filter Class
4-
* @author RedCoder
5-
* http://redframework.ir
6-
*/
7-
8-
namespace Red\SanitizeService;
9-
10-
11-
class Sanitize
12-
{
13-
14-
private static $roles = array();
15-
16-
public static function initialize(){
17-
Rules::rules();
18-
}
19-
20-
public static function sanitize($string, $method)
21-
{
22-
if ($method == 'digit') {
23-
return preg_replace('/([0-9])+/', '', $string);
24-
} else if ($method == 'space') {
25-
$string = preg_replace('/([\s\n])+/', '', $string);
26-
return $string;
27-
}
28-
29-
foreach (self::$roles as $role){
30-
if ($role['role'] == $method){
31-
$result = call_user_func_array($role['callback'], [$string]);
32-
return $result;
33-
}
34-
}
35-
36-
return FALSE;
37-
}
38-
39-
/**
40-
* @param string $role
41-
* @param callable $callback
42-
* @return bool
43-
*/
44-
public static function addRole($role, $callback)
45-
{
46-
47-
array_push(self::$roles, ['role' => $role, 'callback' => $callback]);
48-
return TRUE;
49-
}
50-
51-
/**
52-
* @return mixed
53-
*/
54-
public static function getRoles()
55-
{
56-
return self::$roles;
57-
}
58-
59-
1+
<?php
2+
/** Red Framework
3+
* Filter Class
4+
* @author RedCoder
5+
* http://redframework.ir
6+
*/
7+
8+
namespace Red\SanitizeService;
9+
10+
11+
class Sanitize
12+
{
13+
14+
private static $rules = array();
15+
16+
public static function initialize(){
17+
Rules::rules();
18+
}
19+
20+
public static function sanitize($string, $method)
21+
{
22+
if ($method == 'digit') {
23+
return preg_replace('/([0-9])+/', '', $string);
24+
} else if ($method == 'space') {
25+
$string = preg_replace('/([\s\n])+/', '', $string);
26+
return $string;
27+
}
28+
29+
foreach (self::$rules as $rule){
30+
if ($rule['rule'] == $method){
31+
$result = call_user_func_array($rule['callback'], [$string]);
32+
return $result;
33+
}
34+
}
35+
36+
return FALSE;
37+
}
38+
39+
/**
40+
* @param string $role
41+
* @param callable $callback
42+
* @return bool
43+
*/
44+
public static function addRole($rule, $callback)
45+
{
46+
47+
array_push(self::$rules, ['rule' => $rule, 'callback' => $callback]);
48+
return TRUE;
49+
}
50+
51+
/**
52+
* @return mixed
53+
*/
54+
public static function getRules()
55+
{
56+
return self::$rules;
57+
}
58+
59+
6060
}

0 commit comments

Comments
 (0)