1 | <?php |
||
11 | trait FilterValidation |
||
12 | { |
||
13 | /** |
||
14 | * Check if input is integer and stay |
||
15 | * in range between $min and $max. |
||
16 | * |
||
17 | * @param mixed $input Input field |
||
18 | * @param int $min Min range of input |
||
19 | * @param int|string $max Max range of input |
||
20 | * |
||
21 | * @return bool |
||
22 | */ |
||
23 | public function isIntAndBetween($input, $min, $max = "") |
||
37 | |||
38 | /** |
||
39 | * Check if key or value is not of any described types. |
||
40 | * |
||
41 | * @param string $key Value of key |
||
42 | * @param string $keyParams Not-Types of key |
||
43 | * @param string $value Value of value |
||
44 | * @param string|array $valueParams Not-Types of value |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | public function isKeyAndValueAre($key, $keyParams, $value, $valueParams) |
||
58 | |||
59 | /** |
||
60 | * Check if value is any of these types. |
||
61 | * |
||
62 | * @param string $param Value to check |
||
63 | * @param array $types List of types |
||
64 | * |
||
65 | * @return bool |
||
66 | */ |
||
67 | public function isParamOfTypeMultiple($param, $types) |
||
75 | |||
76 | /** |
||
77 | * Check if value is not that type. |
||
78 | * |
||
79 | * @param string $param Value |
||
80 | * @param string $type Type |
||
81 | * |
||
82 | * @return bool |
||
83 | */ |
||
84 | public function isParamOfTypeSingle($param, $type) |
||
92 | |||
93 | /** |
||
94 | * Check if value has a proper value and key a proper type. |
||
95 | * |
||
96 | * @param string $key Key of value |
||
97 | * @param string $keyParam Key possible types |
||
98 | * @param string $param Param value |
||
99 | * @param array $string Param possible values. |
||
100 | * |
||
101 | * @return boolean |
||
102 | */ |
||
103 | public function isParamAValue($key, $keyParam, $param, array $string) |
||
113 | } |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.