Total Complexity | 61 |
Total Lines | 317 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
117 | class DDC3634LastInsertIdMockingConnection extends Connection |
||
118 | { |
||
119 | /** @var Connection */ |
||
120 | private $realConnection; |
||
121 | |||
122 | /** @var string */ |
||
123 | private $identifier; |
||
124 | |||
125 | /** |
||
126 | * @param string $identifier |
||
127 | */ |
||
128 | public function __construct($identifier, Connection $realConnection) |
||
129 | { |
||
130 | $this->realConnection = $realConnection; |
||
131 | $this->identifier = $identifier; |
||
132 | } |
||
133 | |||
134 | private function forwardCall() |
||
135 | { |
||
136 | $trace = debug_backtrace(0, 2)[1]; |
||
137 | |||
138 | return call_user_func_array([$this->realConnection, $trace['function']], $trace['args']); |
||
139 | } |
||
140 | |||
141 | public function getParams() : array |
||
142 | { |
||
143 | return $this->forwardCall(); |
||
144 | } |
||
145 | |||
146 | public function getDatabase() : string |
||
147 | { |
||
148 | return $this->forwardCall(); |
||
149 | } |
||
150 | |||
151 | public function getHost() |
||
152 | { |
||
153 | return $this->forwardCall(); |
||
154 | } |
||
155 | |||
156 | public function getPort() |
||
157 | { |
||
158 | return $this->forwardCall(); |
||
159 | } |
||
160 | |||
161 | public function getUsername() |
||
162 | { |
||
163 | return $this->forwardCall(); |
||
164 | } |
||
165 | |||
166 | public function getPassword() |
||
167 | { |
||
168 | return $this->forwardCall(); |
||
169 | } |
||
170 | |||
171 | public function getDriver() : Driver |
||
172 | { |
||
173 | return $this->forwardCall(); |
||
174 | } |
||
175 | |||
176 | public function getConfiguration() : Configuration |
||
177 | { |
||
178 | return $this->forwardCall(); |
||
179 | } |
||
180 | |||
181 | public function getEventManager() : EventManager |
||
182 | { |
||
183 | return $this->forwardCall(); |
||
184 | } |
||
185 | |||
186 | public function getDatabasePlatform() : AbstractPlatform |
||
187 | { |
||
188 | return $this->forwardCall(); |
||
189 | } |
||
190 | |||
191 | public function getExpressionBuilder() : ExpressionBuilder |
||
192 | { |
||
193 | return $this->forwardCall(); |
||
194 | } |
||
195 | |||
196 | public function connect() : void |
||
197 | { |
||
198 | $this->forwardCall(); |
||
199 | } |
||
200 | |||
201 | public function isAutoCommit() : bool |
||
202 | { |
||
203 | return $this->forwardCall(); |
||
204 | } |
||
205 | |||
206 | public function setAutoCommit($autoCommit) : void |
||
207 | { |
||
208 | $this->forwardCall(); |
||
209 | } |
||
210 | |||
211 | public function setFetchMode($fetchMode) : void |
||
212 | { |
||
213 | $this->forwardCall(); |
||
214 | } |
||
215 | |||
216 | public function fetchAssoc($statement, array $params = [], array $types = []) |
||
217 | { |
||
218 | return $this->forwardCall(); |
||
219 | } |
||
220 | |||
221 | public function fetchArray($statement, array $params = [], array $types = []) |
||
222 | { |
||
223 | return $this->forwardCall(); |
||
224 | } |
||
225 | |||
226 | public function fetchColumn($statement, array $params = [], $column = 0, array $types = []) |
||
227 | { |
||
228 | return $this->forwardCall(); |
||
229 | } |
||
230 | |||
231 | public function isConnected() : bool |
||
232 | { |
||
233 | return $this->forwardCall(); |
||
234 | } |
||
235 | |||
236 | public function isTransactionActive() : bool |
||
237 | { |
||
238 | return $this->forwardCall(); |
||
239 | } |
||
240 | |||
241 | public function delete($tableExpression, array $identifier, array $types = []) : int |
||
242 | { |
||
243 | return $this->forwardCall(); |
||
244 | } |
||
245 | |||
246 | public function close() : void |
||
247 | { |
||
248 | $this->forwardCall(); |
||
249 | } |
||
250 | |||
251 | public function setTransactionIsolation($level) : void |
||
252 | { |
||
253 | $this->forwardCall(); |
||
254 | } |
||
255 | |||
256 | public function getTransactionIsolation() : int |
||
257 | { |
||
258 | return $this->forwardCall(); |
||
259 | } |
||
260 | |||
261 | public function update($tableExpression, array $data, array $identifier, array $types = []) : int |
||
262 | { |
||
263 | return $this->forwardCall(); |
||
264 | } |
||
265 | |||
266 | public function insert($tableExpression, array $data, array $types = []) : int |
||
267 | { |
||
268 | return $this->forwardCall(); |
||
269 | } |
||
270 | |||
271 | public function quoteIdentifier($str) : string |
||
272 | { |
||
273 | return $this->forwardCall(); |
||
274 | } |
||
275 | |||
276 | public function quote($input, $type = null) : string |
||
277 | { |
||
278 | return $this->forwardCall(); |
||
279 | } |
||
280 | |||
281 | public function fetchAll($sql, array $params = [], $types = []) : array |
||
282 | { |
||
283 | return $this->forwardCall(); |
||
284 | } |
||
285 | |||
286 | public function prepare(string $statement) : Statement |
||
287 | { |
||
288 | return $this->forwardCall(); |
||
289 | } |
||
290 | |||
291 | public function executeQuery(string $query, array $params = [], $types = [], ?QueryCacheProfile $qcp = null) : ResultStatement |
||
292 | { |
||
293 | return $this->forwardCall(); |
||
294 | } |
||
295 | |||
296 | public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qcp) : ResultStatement |
||
297 | { |
||
298 | return $this->forwardCall(); |
||
299 | } |
||
300 | |||
301 | public function project($query, array $params, Closure $function) : array |
||
302 | { |
||
303 | return $this->forwardCall(); |
||
304 | } |
||
305 | |||
306 | public function query(string $sql) : ResultStatement |
||
307 | { |
||
308 | return $this->forwardCall(); |
||
309 | } |
||
310 | |||
311 | public function executeUpdate(string $query, array $params = [], array $types = []) : int |
||
312 | { |
||
313 | return $this->forwardCall(); |
||
314 | } |
||
315 | |||
316 | public function exec(string $statement) : int |
||
317 | { |
||
318 | return $this->forwardCall(); |
||
319 | } |
||
320 | |||
321 | public function getTransactionNestingLevel() : int |
||
322 | { |
||
323 | return $this->forwardCall(); |
||
324 | } |
||
325 | |||
326 | public function errorCode() |
||
327 | { |
||
328 | return $this->forwardCall(); |
||
329 | } |
||
330 | |||
331 | public function errorInfo() |
||
332 | { |
||
333 | return $this->forwardCall(); |
||
334 | } |
||
335 | |||
336 | public function lastInsertId($seqName = null) : string |
||
337 | { |
||
338 | return $this->identifier; |
||
339 | } |
||
340 | |||
341 | public function transactional(Closure $func) |
||
342 | { |
||
343 | return $this->forwardCall(); |
||
344 | } |
||
345 | |||
346 | public function setNestTransactionsWithSavepoints($nestTransactionsWithSavepoints) : void |
||
347 | { |
||
348 | $this->forwardCall(); |
||
349 | } |
||
350 | |||
351 | public function getNestTransactionsWithSavepoints() : bool |
||
352 | { |
||
353 | return $this->forwardCall(); |
||
354 | } |
||
355 | |||
356 | protected function getNestedTransactionSavePointName() |
||
357 | { |
||
358 | return $this->forwardCall(); |
||
359 | } |
||
360 | |||
361 | public function beginTransaction() : void |
||
364 | } |
||
365 | |||
366 | public function commit() : void |
||
367 | { |
||
368 | $this->forwardCall(); |
||
369 | } |
||
370 | |||
371 | public function rollBack() : void |
||
372 | { |
||
373 | $this->forwardCall(); |
||
374 | } |
||
375 | |||
376 | public function createSavepoint($savepoint) : void |
||
377 | { |
||
378 | $this->forwardCall(); |
||
379 | } |
||
380 | |||
381 | public function releaseSavepoint($savepoint) : void |
||
382 | { |
||
383 | $this->forwardCall(); |
||
384 | } |
||
385 | |||
386 | public function rollbackSavepoint($savepoint) : void |
||
387 | { |
||
388 | $this->forwardCall(); |
||
389 | } |
||
390 | |||
391 | public function getWrappedConnection() : \Doctrine\DBAL\Driver\Connection |
||
394 | } |
||
395 | |||
396 | public function getSchemaManager() : AbstractSchemaManager |
||
397 | { |
||
398 | return $this->forwardCall(); |
||
399 | } |
||
400 | |||
401 | public function setRollbackOnly() : void |
||
402 | { |
||
403 | $this->forwardCall(); |
||
404 | } |
||
405 | |||
406 | public function isRollbackOnly() : bool |
||
409 | } |
||
410 | |||
411 | public function convertToDatabaseValue($value, $type) |
||
412 | { |
||
413 | return $this->forwardCall(); |
||
414 | } |
||
415 | |||
416 | public function convertToPHPValue($value, $type) |
||
417 | { |
||
418 | return $this->forwardCall(); |
||
419 | } |
||
420 | |||
421 | public function resolveParams(array $params, array $types) : array |
||
422 | { |
||
423 | return $this->forwardCall(); |
||
424 | } |
||
425 | |||
426 | public function createQueryBuilder() : QueryBuilder |
||
427 | { |
||
428 | return $this->forwardCall(); |
||
429 | } |
||
430 | |||
431 | public function ping() : void |
||
434 | } |
||
435 | } |
||
436 |
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.