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 CustomColumnTypeInteger extends CustomColumnType |
||
|
|
|||
| 10 | { |
||
| 11 | 1 | protected function __construct($pcustomId) |
|
| 15 | |||
| 16 | /** |
||
| 17 | * Get the name of the sqlite table for this column |
||
| 18 | * |
||
| 19 | * @return string|null |
||
| 20 | */ |
||
| 21 | 5 | private function getTableName() |
|
| 25 | |||
| 26 | 2 | public function getQuery($id) |
|
| 31 | |||
| 32 | 2 | public function getCustom($id) |
|
| 36 | |||
| 37 | 1 | View Code Duplication | protected function getAllCustomValuesFromDatabase() |
| 54 | |||
| 55 | 3 | public function getDescription() |
|
| 61 | |||
| 62 | 2 | public function getCustomByBook($book) |
|
| 73 | |||
| 74 | 3 | public function isSearchable() |
|
| 78 | } |
||
| 79 |
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.