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 |
||
| 30 | trait LimitTrait |
||
| 31 | { |
||
| 32 | use AbstractTrait; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * {@inheritDoc} |
||
| 36 | */ |
||
| 37 | public function limit(/*# int */ $count, /*# int */ $offset = 0) |
||
| 49 | |||
| 50 | /** |
||
| 51 | * {@inheritDoc} |
||
| 52 | */ |
||
| 53 | public function offset(/*# int */ $offset) |
||
| 63 | |||
| 64 | /** |
||
| 65 | * {@inheritDoc} |
||
| 66 | */ |
||
| 67 | public function page(/*# int */ $pageNumber, /*# int */ $perPage = 30) |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Build LIMIT |
||
| 76 | * |
||
| 77 | * @param string $prefix |
||
| 78 | * @param settings |
||
| 79 | * @return array |
||
| 80 | * @access protected |
||
| 81 | */ |
||
| 82 | protected function buildLimit( |
||
| 100 | } |
||
| 101 |