1 | <?php |
||
8 | class FeaturedFlagsImpl implements FeaturedFlags |
||
9 | { |
||
10 | protected $_pdo; |
||
11 | protected $_redis; |
||
12 | protected $_date; |
||
13 | |||
14 | CONST TABLE_NAME = 'featured_flags'; |
||
15 | |||
16 | /** |
||
17 | * FeaturedFlags constructor. |
||
18 | * @param PDO $pdo |
||
19 | * @param Redis|null $redis |
||
20 | * @param string|null $date |
||
21 | */ |
||
22 | public function __construct(PDO $pdo, Redis $redis = null, $date = null) |
||
32 | |||
33 | /** |
||
34 | * @param PDO $pdo |
||
35 | * @param Redis $redis |
||
36 | * @return FeaturedFlags |
||
37 | */ |
||
38 | public static function getInstance(PDO $pdo, Redis $redis = null) { |
||
41 | |||
42 | /** |
||
43 | * @param string $flagName |
||
44 | * @param array $filterParams |
||
45 | * @return boolean |
||
46 | */ |
||
47 | public function isEnabled($flagName, $filterParams = null) |
||
67 | |||
68 | /** |
||
69 | * @param $flagName |
||
70 | * @param $filterParams |
||
71 | * @return null|array |
||
72 | */ |
||
73 | public function getEnabledValues($flagName, $filterParams = null) |
||
94 | |||
95 | /** |
||
96 | * @param Redis $redis |
||
97 | */ |
||
98 | public function setRedis(Redis $redis) |
||
102 | |||
103 | /** |
||
104 | * @return string |
||
105 | */ |
||
106 | private function _getDate() { |
||
113 | |||
114 | /** |
||
115 | * @param string $query |
||
116 | * @param array $params |
||
117 | * @return \mysqli_stmt |
||
118 | */ |
||
119 | private function _getStmt($query, $params) |
||
127 | |||
128 | /** |
||
129 | * @param string $flagName |
||
130 | * @return array |
||
131 | */ |
||
132 | private function _getDBFlagsData($flagName) |
||
153 | |||
154 | /** |
||
155 | * @param string $query |
||
156 | * @param array $params |
||
157 | * @return array |
||
158 | */ |
||
159 | private function _executeForSelect($query, $params = array()) |
||
165 | |||
166 | /** |
||
167 | * @param array $flagParams |
||
168 | * @param array $filterParams |
||
169 | * @return boolean |
||
170 | */ |
||
171 | private function _compareParams($flagParams, $filterParams) |
||
181 | |||
182 | /** |
||
183 | * @param string $flagParamsJson |
||
184 | * @param array $filterParams |
||
185 | * @return boolean |
||
186 | */ |
||
187 | private function _checkParams($flagParamsJson, $filterParams = null) |
||
200 | |||
201 | /** |
||
202 | * @param string $flagName |
||
203 | * @param array $filterParams |
||
204 | * @return boolean |
||
205 | */ |
||
206 | private function _getKey($flagName, $filterParams) |
||
210 | |||
211 | /** |
||
212 | * @param string $endDate |
||
213 | * @return int |
||
214 | */ |
||
215 | private function _getTimeout($endDate) |
||
223 | } |
||
224 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: