1 | <?php |
||
15 | class CheckHelper |
||
16 | { |
||
17 | protected static $allRules = []; |
||
18 | |||
19 | /** |
||
20 | * Check if data satisfies the condition |
||
21 | * |
||
22 | * @param mixed $data |
||
23 | * @param array $conditions |
||
24 | * @return bool |
||
25 | */ |
||
26 | public static function check($data, array $conditions) : bool |
||
41 | |||
42 | /** |
||
43 | * If array of rules is in "simple format" |
||
44 | * convert it to full format |
||
45 | * |
||
46 | * @param array $rules |
||
47 | * @return array |
||
48 | */ |
||
49 | protected static function tryPrepareSimpleRules(array $rules) : array |
||
62 | |||
63 | /** |
||
64 | * Init list of rules if not initialized |
||
65 | * |
||
66 | * @return void |
||
67 | */ |
||
68 | public static function initAllRules() : void |
||
85 | |||
86 | /** |
||
87 | * Check AND condition |
||
88 | * |
||
89 | * @param mixed $data |
||
90 | * @param array $conditions |
||
91 | * @return bool |
||
92 | */ |
||
93 | protected static function checkAnd($data, array $conditions) : bool |
||
102 | |||
103 | /** |
||
104 | * Check OR condition |
||
105 | * |
||
106 | * @param mixed $data |
||
107 | * @param array $conditions |
||
108 | * @return bool |
||
109 | */ |
||
110 | protected static function checkOr($data, array $conditions) : bool |
||
119 | |||
120 | /** |
||
121 | * Check/compare some field by rule and some value |
||
122 | * |
||
123 | * @param mixed $data |
||
124 | * @param string $staredRule |
||
125 | * @param mixed $arg1 |
||
126 | * @param mixed $arg2 |
||
127 | * @return bool |
||
128 | */ |
||
129 | protected static function checkField($data, string $staredRule, $arg1, $arg2) : bool |
||
140 | } |
||
141 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.