1 | <?php |
||
23 | class PDOAdapter implements DataAdapterInterface |
||
24 | { |
||
25 | /** @var PDO */ |
||
26 | private $dataStorage; |
||
27 | /** @var string */ |
||
28 | private $dataGroup = null; |
||
29 | /** @var string */ |
||
30 | private $idKey = null; |
||
31 | |||
32 | /** |
||
33 | * PDOAdapter constructor. |
||
34 | * |
||
35 | * @param PDO $dataStorage |
||
36 | * |
||
37 | * @throws InvalidArgumentException |
||
38 | */ |
||
39 | 10 | public function __construct($dataStorage = null) |
|
59 | |||
60 | /** |
||
61 | * Returns the Data Storage instance. |
||
62 | * |
||
63 | * @return PDO |
||
64 | */ |
||
65 | 1 | public function getDataStorage() |
|
69 | |||
70 | /** |
||
71 | * Set adapter data group. For Databases this can be the Tables. |
||
72 | * |
||
73 | * @param string $dataGroup |
||
74 | * |
||
75 | * @throws RuntimeException |
||
76 | * |
||
77 | * @return PDOAdapter |
||
78 | */ |
||
79 | 4 | public function setDataGroup($dataGroup) |
|
89 | |||
90 | /** |
||
91 | * Set adapter ID key. For Databases this can be the Primary key. Only simple key is allowed. |
||
92 | * |
||
93 | * @param string $idKey |
||
94 | * |
||
95 | * @throws RuntimeException |
||
96 | * |
||
97 | * @return PDOAdapter |
||
98 | */ |
||
99 | 1 | public function setIdKey($idKey) |
|
109 | |||
110 | /** |
||
111 | * Get exactly one "row" of data according to the expression. |
||
112 | * |
||
113 | * @param mixed $identifier |
||
114 | * |
||
115 | * @return array |
||
116 | * |
||
117 | * @codeCoverageIgnore Don't test external library. |
||
118 | */ |
||
119 | public function getData($identifier) |
||
130 | |||
131 | /** |
||
132 | * Get a set of data according to the expression and the chunk. |
||
133 | * |
||
134 | * @param array $expression |
||
135 | * @param int $limit |
||
136 | * @param int $offset |
||
137 | * |
||
138 | * @return array |
||
139 | * |
||
140 | * @codeCoverageIgnore Don't test external library. |
||
141 | */ |
||
142 | public function getDataSet(array $expression, $limit = PHP_INT_MAX, $offset = 0) |
||
153 | |||
154 | /** |
||
155 | * Get the number of matched data in the set according to the expression. |
||
156 | * |
||
157 | * @param array $expression |
||
158 | * |
||
159 | * @return int |
||
160 | * |
||
161 | * @codeCoverageIgnore Don't test external library. |
||
162 | */ |
||
163 | public function getDataCardinality(array $expression) |
||
174 | |||
175 | /** |
||
176 | * Builds SQL query from the expression. |
||
177 | * |
||
178 | * @param array $expression |
||
179 | * @param array $queryBind |
||
180 | * @param int $limit |
||
181 | * @param int $offset |
||
182 | * |
||
183 | * @return string |
||
184 | */ |
||
185 | 3 | private function getSelectQueryForExpression( |
|
203 | |||
204 | /** |
||
205 | * Creates a WHERE expression for the SQL query. |
||
206 | * |
||
207 | * @param array $expression |
||
208 | * @param array $queryBind |
||
209 | * |
||
210 | * @return string |
||
211 | */ |
||
212 | 5 | private function getWhereExpression(array $expression, array &$queryBind) |
|
230 | |||
231 | /** |
||
232 | * Insert or update entity in the storage. |
||
233 | * |
||
234 | * @param mixed $identifier |
||
235 | * @param array $data |
||
236 | * |
||
237 | * @return mixed The ID of the saved entity in the storage |
||
238 | * |
||
239 | * @codeCoverageIgnore Don't test external library. |
||
240 | */ |
||
241 | public function saveData($identifier, array $data) |
||
270 | |||
271 | /** |
||
272 | * Binds values to the statement. |
||
273 | * |
||
274 | * @param PDOStatement $statement |
||
275 | * @param array $queryBind |
||
276 | * |
||
277 | * @codeCoverageIgnore Don't test external library. |
||
278 | */ |
||
279 | private function bindValuesToStatement(PDOStatement &$statement, array $queryBind) |
||
293 | |||
294 | /** |
||
295 | * Removes an entity from the storage. |
||
296 | * |
||
297 | * @param mixed $identifier |
||
298 | * |
||
299 | * @return bool |
||
300 | * |
||
301 | * @codeCoverageIgnore Don't test external library. |
||
302 | */ |
||
303 | public function deleteData($identifier) |
||
309 | } |
||
310 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.