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 |
||
21 | class BaseMapper extends Mapper { |
||
22 | |||
23 | public function __construct(IDBConnection $db, $tableName, $entityClass=null){ |
||
26 | |||
27 | /** |
||
28 | * @param integer[] $ids IDs of the entities to be deleted |
||
29 | */ |
||
30 | public function deleteById($ids){ |
||
38 | |||
39 | /** |
||
40 | * @param string $userId |
||
41 | */ |
||
42 | View Code Duplication | public function count($userId){ |
|
50 | |||
51 | /** |
||
52 | * helper creating a string like '(?,?,?)' with the specified number of elements |
||
53 | * @param int $count |
||
54 | */ |
||
55 | protected function questionMarks($count) { |
||
62 | |||
63 | } |
||
64 |