Total Complexity | 9 |
Total Lines | 96 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
5 | class Rules |
||
6 | { |
||
7 | /** |
||
8 | * Return true if value is alpha characters. |
||
9 | * |
||
10 | * @param mixed $value |
||
11 | * |
||
12 | * @return bool |
||
13 | */ |
||
14 | public static function ruleAlpha($value) |
||
15 | { |
||
16 | return ctype_alpha($value); |
||
17 | } |
||
18 | |||
19 | /** |
||
20 | * Return true for everything. |
||
21 | * |
||
22 | * @return bool |
||
23 | */ |
||
24 | public static function ruleAny() |
||
25 | { |
||
26 | return true; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Return true if value is alpha characters. |
||
31 | * |
||
32 | * @param mixed $value |
||
33 | * |
||
34 | * @return bool |
||
35 | */ |
||
36 | public static function ruleAlphanum($value) |
||
37 | { |
||
38 | return ctype_alnum($value); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Return true if value is alpha characters. |
||
43 | * |
||
44 | * @param mixed $value |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | public static function ruleBool($value) |
||
49 | { |
||
50 | return is_bool($value); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Return true if value is integer. |
||
55 | * |
||
56 | * @param mixed $value |
||
57 | * |
||
58 | * @return bool |
||
59 | */ |
||
60 | public static function ruleInt($value) |
||
61 | { |
||
62 | return is_int($value); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Return true if value is numeric. |
||
67 | * |
||
68 | * @param mixed $value |
||
69 | * |
||
70 | * @return bool |
||
71 | */ |
||
72 | public static function ruleNum($value) |
||
73 | { |
||
74 | return is_numeric($value); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Return true if value is numeric. |
||
79 | * |
||
80 | * @param mixed $value |
||
81 | * @param int $low |
||
82 | * @param int $high |
||
83 | * |
||
84 | * @return bool |
||
85 | */ |
||
86 | public static function ruleRange($value, $low, $high) |
||
87 | { |
||
88 | return ($low <= $value) && ($value <= $high); |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Return true if value is a string. |
||
93 | * |
||
94 | * @param mixed $value |
||
95 | * |
||
96 | * @return bool |
||
97 | */ |
||
98 | public static function ruleString($value) |
||
101 | } |
||
102 | } |
||
103 |