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 Cart extends Prestashop |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @param string $data |
||
| 14 | */ |
||
| 15 | View Code Duplication | private function getCartData($data) |
|
| 25 | |||
| 26 | /** |
||
| 27 | * @param string $cart |
||
| 28 | * @param string $cust |
||
| 29 | */ |
||
| 30 | View Code Duplication | private function processFindCarts($cart, $cust) |
|
| 48 | |||
| 49 | } |
Overwriting private methods is generally fine as long as you also use private visibility. It might still be preferable for understandability to use a different method name.