Total Complexity | 61 |
Total Lines | 322 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like DDC3634LastInsertIdMockingConnection often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DDC3634LastInsertIdMockingConnection, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
104 | class DDC3634LastInsertIdMockingConnection extends Connection |
||
105 | { |
||
106 | /** |
||
107 | * @var Connection |
||
108 | */ |
||
109 | private $realConnection; |
||
110 | |||
111 | /** |
||
112 | * @var int |
||
113 | */ |
||
114 | private $identifier; |
||
115 | |||
116 | /** |
||
117 | * @param int $identifier |
||
118 | * @param Connection $realConnection |
||
119 | */ |
||
120 | public function __construct($identifier, Connection $realConnection) |
||
121 | { |
||
122 | $this->realConnection = $realConnection; |
||
123 | $this->identifier = $identifier; |
||
124 | } |
||
125 | |||
126 | private function forwardCall() |
||
127 | { |
||
128 | $trace = debug_backtrace(0, 2)[1]; |
||
129 | |||
130 | return call_user_func_array([$this->realConnection, $trace['function']], $trace['args']); |
||
131 | } |
||
132 | |||
133 | public function getParams() |
||
134 | { |
||
135 | return $this->forwardCall(); |
||
136 | } |
||
137 | |||
138 | public function getDatabase() |
||
139 | { |
||
140 | return $this->forwardCall(); |
||
141 | } |
||
142 | |||
143 | public function getHost() |
||
144 | { |
||
145 | return $this->forwardCall(); |
||
146 | } |
||
147 | |||
148 | public function getPort() |
||
149 | { |
||
150 | return $this->forwardCall(); |
||
151 | } |
||
152 | |||
153 | public function getUsername() |
||
154 | { |
||
155 | return $this->forwardCall(); |
||
156 | } |
||
157 | |||
158 | public function getPassword() |
||
159 | { |
||
160 | return $this->forwardCall(); |
||
161 | } |
||
162 | |||
163 | public function getDriver() |
||
164 | { |
||
165 | return $this->forwardCall(); |
||
166 | } |
||
167 | |||
168 | public function getConfiguration() |
||
169 | { |
||
170 | return $this->forwardCall(); |
||
171 | } |
||
172 | |||
173 | public function getEventManager() |
||
174 | { |
||
175 | return $this->forwardCall(); |
||
176 | } |
||
177 | |||
178 | public function getDatabasePlatform() |
||
179 | { |
||
180 | return $this->forwardCall(); |
||
181 | } |
||
182 | |||
183 | public function getExpressionBuilder() |
||
184 | { |
||
185 | return $this->forwardCall(); |
||
186 | } |
||
187 | |||
188 | public function connect() |
||
189 | { |
||
190 | return $this->forwardCall(); |
||
191 | } |
||
192 | |||
193 | public function isAutoCommit() |
||
194 | { |
||
195 | return $this->forwardCall(); |
||
196 | } |
||
197 | |||
198 | public function setAutoCommit($autoCommit) |
||
199 | { |
||
200 | return $this->forwardCall(); |
||
201 | } |
||
202 | |||
203 | public function setFetchMode($fetchMode) |
||
204 | { |
||
205 | return $this->forwardCall(); |
||
206 | } |
||
207 | |||
208 | public function fetchAssoc($statement, array $params = [], array $types = []) |
||
209 | { |
||
210 | return $this->forwardCall(); |
||
211 | } |
||
212 | |||
213 | public function fetchArray($statement, array $params = [], array $types = []) |
||
214 | { |
||
215 | return $this->forwardCall(); |
||
216 | } |
||
217 | |||
218 | public function fetchColumn($statement, array $params = [], $column = 0, array $types = []) |
||
219 | { |
||
220 | return $this->forwardCall(); |
||
221 | } |
||
222 | |||
223 | public function isConnected() |
||
224 | { |
||
225 | return $this->forwardCall(); |
||
226 | } |
||
227 | |||
228 | public function isTransactionActive() |
||
229 | { |
||
230 | return $this->forwardCall(); |
||
231 | } |
||
232 | |||
233 | public function delete($tableExpression, array $identifier, array $types = []) |
||
234 | { |
||
235 | return $this->forwardCall(); |
||
236 | } |
||
237 | |||
238 | public function close() |
||
239 | { |
||
240 | return $this->forwardCall(); |
||
241 | } |
||
242 | |||
243 | public function setTransactionIsolation($level) |
||
244 | { |
||
245 | return $this->forwardCall(); |
||
246 | } |
||
247 | |||
248 | public function getTransactionIsolation() |
||
249 | { |
||
250 | return $this->forwardCall(); |
||
251 | } |
||
252 | |||
253 | public function update($tableExpression, array $data, array $identifier, array $types = []) |
||
254 | { |
||
255 | return $this->forwardCall(); |
||
256 | } |
||
257 | |||
258 | public function insert($tableExpression, array $data, array $types = []) |
||
259 | { |
||
260 | return $this->forwardCall(); |
||
261 | } |
||
262 | |||
263 | public function quoteIdentifier($str) |
||
264 | { |
||
265 | return $this->forwardCall(); |
||
266 | } |
||
267 | |||
268 | public function quote($input, $type = null) |
||
269 | { |
||
270 | return $this->forwardCall(); |
||
271 | } |
||
272 | |||
273 | public function fetchAll($sql, array $params = [], $types = []) |
||
274 | { |
||
275 | return $this->forwardCall(); |
||
276 | } |
||
277 | |||
278 | public function prepare($statement) |
||
279 | { |
||
280 | return $this->forwardCall(); |
||
281 | } |
||
282 | |||
283 | public function executeQuery($query, array $params = [], $types = [], QueryCacheProfile $qcp = null) |
||
284 | { |
||
285 | return $this->forwardCall(); |
||
286 | } |
||
287 | |||
288 | public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qcp) |
||
289 | { |
||
290 | return $this->forwardCall(); |
||
291 | } |
||
292 | |||
293 | public function project($query, array $params, \Closure $function) |
||
294 | { |
||
295 | return $this->forwardCall(); |
||
296 | } |
||
297 | |||
298 | public function query() |
||
299 | { |
||
300 | return $this->forwardCall(); |
||
301 | } |
||
302 | |||
303 | public function executeUpdate($query, array $params = [], array $types = []) |
||
304 | { |
||
305 | return $this->forwardCall(); |
||
306 | } |
||
307 | |||
308 | public function exec($statement) |
||
309 | { |
||
310 | return $this->forwardCall(); |
||
311 | } |
||
312 | |||
313 | public function getTransactionNestingLevel() |
||
314 | { |
||
315 | return $this->forwardCall(); |
||
316 | } |
||
317 | |||
318 | public function errorCode() |
||
319 | { |
||
320 | return $this->forwardCall(); |
||
321 | } |
||
322 | |||
323 | public function errorInfo() |
||
324 | { |
||
325 | return $this->forwardCall(); |
||
326 | } |
||
327 | |||
328 | public function lastInsertId($seqName = null) |
||
329 | { |
||
330 | return $this->identifier; |
||
331 | } |
||
332 | |||
333 | public function transactional(\Closure $func) |
||
334 | { |
||
335 | return $this->forwardCall(); |
||
336 | } |
||
337 | |||
338 | public function setNestTransactionsWithSavepoints($nestTransactionsWithSavepoints) |
||
339 | { |
||
340 | return $this->forwardCall(); |
||
341 | } |
||
342 | |||
343 | public function getNestTransactionsWithSavepoints() |
||
344 | { |
||
345 | return $this->forwardCall(); |
||
346 | } |
||
347 | |||
348 | protected function getNestedTransactionSavePointName() |
||
349 | { |
||
350 | return $this->forwardCall(); |
||
351 | } |
||
352 | |||
353 | public function beginTransaction() |
||
356 | } |
||
357 | |||
358 | public function commit() |
||
359 | { |
||
360 | return $this->forwardCall(); |
||
361 | } |
||
362 | |||
363 | public function rollBack() |
||
364 | { |
||
365 | return $this->forwardCall(); |
||
366 | } |
||
367 | |||
368 | public function createSavepoint($savepoint) |
||
369 | { |
||
370 | return $this->forwardCall(); |
||
371 | } |
||
372 | |||
373 | public function releaseSavepoint($savepoint) |
||
374 | { |
||
375 | return $this->forwardCall(); |
||
376 | } |
||
377 | |||
378 | public function rollbackSavepoint($savepoint) |
||
379 | { |
||
380 | return $this->forwardCall(); |
||
381 | } |
||
382 | |||
383 | public function getWrappedConnection() |
||
386 | } |
||
387 | |||
388 | public function getSchemaManager() |
||
389 | { |
||
390 | return $this->forwardCall(); |
||
391 | } |
||
392 | |||
393 | public function setRollbackOnly() |
||
394 | { |
||
395 | return $this->forwardCall(); |
||
396 | } |
||
397 | |||
398 | public function isRollbackOnly() |
||
401 | } |
||
402 | |||
403 | public function convertToDatabaseValue($value, $type) |
||
404 | { |
||
405 | return $this->forwardCall(); |
||
406 | } |
||
407 | |||
408 | public function convertToPHPValue($value, $type) |
||
409 | { |
||
410 | return $this->forwardCall(); |
||
411 | } |
||
412 | |||
413 | public function resolveParams(array $params, array $types) |
||
414 | { |
||
415 | return $this->forwardCall(); |
||
416 | } |
||
417 | |||
418 | public function createQueryBuilder() |
||
419 | { |
||
420 | return $this->forwardCall(); |
||
421 | } |
||
422 | |||
423 | public function ping() |
||
426 | } |
||
427 | } |
||
428 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.