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 TransfersList extends MoipResource |
||
10 | { |
||
11 | /** |
||
12 | * Path bank accounts API. |
||
13 | * |
||
14 | * @const string |
||
15 | */ |
||
16 | const PATH = 'transfers'; |
||
17 | |||
18 | /** |
||
19 | * Initialize a new instance. |
||
20 | */ |
||
21 | public function initialize() |
||
26 | |||
27 | /** |
||
28 | * Get transfers. |
||
29 | * |
||
30 | * @return array |
||
31 | */ |
||
32 | public function getTransfers() |
||
36 | |||
37 | /** |
||
38 | * Get transfer list. |
||
39 | * |
||
40 | * @param Pagination $pagination |
||
41 | * @param Filters $filters |
||
42 | * @param string $qParam Query a specific value. |
||
43 | * |
||
44 | * @return stdClass |
||
45 | */ |
||
46 | public function get(Pagination $pagination = null, Filters $filters = null, $qParam = '') |
||
50 | |||
51 | View Code Duplication | protected function populate(stdClass $response) |
|
63 | } |
||
64 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.