Conditions | 3 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | public static function interpolateQuery($query, $params) |
||
23 | { |
||
24 | $keys = array(); |
||
25 | |||
26 | # build a regular expression for each parameter |
||
27 | foreach ($params as $key => $value) { |
||
28 | $keys[] = is_string($key) ? '/:'.$key.'/' : '/[?]/'; |
||
29 | $params[$key] = "'" . $value . "'"; |
||
30 | } |
||
31 | |||
32 | return preg_replace($keys, $params, $query, 1, $count); |
||
33 | } |
||
34 | } |
||
35 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: