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 |
||
| 22 | class History extends AbstractStorage |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * Get name of mongo collection |
||
| 26 | * |
||
| 27 | * @access public |
||
| 28 | * @static |
||
| 29 | * @return string |
||
| 30 | */ |
||
| 31 | public static function collectionName() |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Get list of attributes |
||
| 38 | * |
||
| 39 | * @access public |
||
| 40 | * @return array |
||
| 41 | */ |
||
| 42 | View Code Duplication | public function attributes() |
|
| 49 | |||
| 50 | /** |
||
| 51 | * @inheritdoc |
||
| 52 | */ |
||
| 53 | View Code Duplication | public function getHistory($chatId, $limit = 10) |
|
| 65 | |||
| 66 | /** |
||
| 67 | * @inheritdoc |
||
| 68 | */ |
||
| 69 | public function storeMessage(array $params) |
||
| 81 | } |
||
| 82 | |||
| 83 |