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 |
||
19 | class FirewallGroup extends AbstractApi |
||
20 | { |
||
21 | /** |
||
22 | * List all firewall groups on the current account. |
||
23 | * |
||
24 | * @return FirewallGroupEntity |
||
25 | */ |
||
26 | public function list() |
||
32 | |||
33 | /** |
||
34 | * Get a firewall group by its id. |
||
35 | * |
||
36 | * @param string $groupId ID for the firewall group |
||
37 | * |
||
38 | * @return FirewallGroupEntity |
||
39 | * |
||
40 | * @throws EntityNotFoundException |
||
41 | **/ |
||
42 | public function getById($groupId) |
||
54 | |||
55 | /** |
||
56 | * Get a firewall group by its id. |
||
57 | * |
||
58 | * @param string $groupId ID for the firewall group |
||
59 | * |
||
60 | * @return string API response |
||
61 | */ |
||
62 | protected function getAny($groupId = null) |
||
68 | |||
69 | /** |
||
70 | * Create a new firewall group on the current account. |
||
71 | * |
||
72 | * @param string $description Description of firewall group |
||
73 | * |
||
74 | * @return FirewallGroupEntity |
||
75 | **/ |
||
76 | public function create($description = null) |
||
83 | |||
84 | /** |
||
85 | * Change the description on a firewall group. |
||
86 | * |
||
87 | * @param string $groupId Firewall group to update |
||
88 | * @param string $description Description of firewall group |
||
89 | * |
||
90 | * @throws HttpException |
||
91 | */ |
||
92 | View Code Duplication | public function setDescription($groupId, $description) |
|
100 | |||
101 | /** |
||
102 | * Delete a firewall group. |
||
103 | * |
||
104 | * Use this function with caution because the firewall group being deleted |
||
105 | * will be detached from all servers. This can result in open ports accessible |
||
106 | * to the internet |
||
107 | * |
||
108 | * @param string $groupId Firewall group to delete |
||
109 | * |
||
110 | * @throws HttpException |
||
111 | */ |
||
112 | public function delete($groupId) |
||
119 | } |
||
120 |