Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
15 | class PdoExtractor extends DbExtractorAbstract |
||
16 | { |
||
17 | use PdoExtractorTrait; |
||
18 | |||
19 | /** |
||
20 | * @param \PDO $pdo |
||
21 | * @param string|null $extractQuery |
||
22 | */ |
||
23 | public function __construct(\PDO $pdo, $extractQuery = null) |
||
29 | |||
30 | /** |
||
31 | * leave no trace |
||
32 | * implement here to allow easier overidding |
||
33 | */ |
||
34 | public function __destruct() |
||
41 | |||
42 | /** |
||
43 | * @return bool |
||
44 | */ |
||
45 | public function fetchRecords() |
||
67 | |||
68 | /** |
||
69 | * This method sets offset and limit in the query |
||
70 | * WARNING : if you set an offset without limit, |
||
71 | * the limit will be set to $this->maxdefaultLimit |
||
72 | * |
||
73 | * @return string the paginated query with current offset and limit |
||
74 | */ |
||
75 | protected function getPaginatedQuery() |
||
79 | } |
||
80 |