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 |
||
17 | class Boards extends AbstractApi |
||
18 | { |
||
19 | protected $path = 'organizations/#id#/boards'; |
||
20 | |||
21 | /** |
||
22 | * Get boads related to a given organization |
||
23 | * @link https://trello.com/docs/api/organization/#get-1-organizations-idorg-or-name-boards |
||
24 | * |
||
25 | * @param string $id the organization's id or username |
||
26 | * @param array $params optional parameters |
||
27 | * |
||
28 | * @return array |
||
29 | */ |
||
30 | public function all($id, array $params = array()) |
||
34 | |||
35 | /** |
||
36 | * Filter boards related to a given organization |
||
37 | * @link https://trello.com/docs/api/organization/#get-1-organizations-idorg-or-name-boards-filter |
||
38 | * |
||
39 | * @param string $id the board's id |
||
40 | * @param string|array $filter array of / one of 'all', none', 'open', 'closed', 'all' |
||
41 | * |
||
42 | * @return array |
||
43 | */ |
||
44 | View Code Duplication | public function filter($id, $filter = 'all') |
|
51 | } |
||
52 |
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.