Total Complexity | 7 |
Total Lines | 70 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class QueryObject |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $sql; |
||
13 | |||
14 | /** |
||
15 | * @var mixed[] |
||
16 | */ |
||
17 | protected $bindings = []; |
||
18 | |||
19 | /** |
||
20 | * @var wpdb |
||
21 | */ |
||
22 | protected $dbInstance; |
||
23 | |||
24 | /** |
||
25 | * @param string $sql |
||
26 | * @param mixed[] $bindings |
||
27 | * @param wpdb $dbInstance |
||
28 | */ |
||
29 | public function __construct(string $sql, array $bindings, wpdb $dbInstance) |
||
30 | { |
||
31 | $this->sql = (string)$sql; |
||
32 | $this->bindings = $bindings; |
||
33 | $this->dbInstance = $dbInstance; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @return string |
||
38 | */ |
||
39 | public function getSql() |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @return mixed[] |
||
46 | */ |
||
47 | public function getBindings() |
||
48 | { |
||
49 | return $this->bindings; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Get the raw/bound sql |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | public function getRawSql() |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Uses WPDB::prepare() to interpolate the query passed. |
||
64 | |||
65 | * |
||
66 | * @param string $query The sql query with parameter placeholders |
||
67 | * @param mixed[] $params The array of substitution parameters |
||
68 | * |
||
69 | * @return string The interpolated query |
||
70 | */ |
||
71 | protected function interpolateQuery($query, $params): string |
||
77 | } |
||
78 | } |
||
79 |