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 |
||
| 9 | class CustomColumnTypeSeries extends CustomColumnType |
||
|
|
|||
| 10 | { |
||
| 11 | 2 | protected function __construct($pcustomId) |
|
| 15 | |||
| 16 | /** |
||
| 17 | * Get the name of the sqlite table for this column |
||
| 18 | * |
||
| 19 | * @return string|null |
||
| 20 | */ |
||
| 21 | 7 | private function getTableName() |
|
| 25 | |||
| 26 | /** |
||
| 27 | * Get the name of the linking sqlite table for this column |
||
| 28 | * (or NULL if there is no linktable) |
||
| 29 | * |
||
| 30 | * @return string|null |
||
| 31 | */ |
||
| 32 | 7 | private function getTableLinkName() |
|
| 36 | |||
| 37 | /** |
||
| 38 | * Get the name of the linking column in the linktable |
||
| 39 | * |
||
| 40 | * @return string|null |
||
| 41 | */ |
||
| 42 | 7 | private function getTableLinkColumn() |
|
| 46 | |||
| 47 | 3 | public function getQuery($id) |
|
| 52 | |||
| 53 | 3 | public function getCustom($id) |
|
| 62 | |||
| 63 | 2 | View Code Duplication | protected function getAllCustomValuesFromDatabase() |
| 80 | |||
| 81 | 5 | public function getDescription() |
|
| 85 | |||
| 86 | 2 | public function getCustomByBook($book) |
|
| 97 | |||
| 98 | 5 | public function isSearchable() |
|
| 102 | } |
||
| 103 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.