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 |
||
20 | class ClientRemote extends BaseClientRemote |
||
21 | { |
||
22 | /** |
||
23 | * @inheritdoc |
||
24 | */ |
||
25 | 2 | public function getTables(array $params = []) |
|
29 | |||
30 | /** |
||
31 | * @inheritdoc |
||
32 | */ |
||
33 | 4 | public function getTable($tableName) |
|
39 | |||
40 | /** |
||
41 | * @inheritdoc |
||
42 | */ |
||
43 | 2 | public function getColumns($tableName, array $params = []) |
|
49 | |||
50 | /** |
||
51 | * @inheritdoc |
||
52 | */ |
||
53 | 2 | public function getColumn($tableName, $columnName) |
|
59 | |||
60 | /** |
||
61 | * @inheritdoc |
||
62 | */ |
||
63 | 2 | public function getEntries($tableName, array $options = []) |
|
69 | |||
70 | /** |
||
71 | * @inheritdoc |
||
72 | */ |
||
73 | 2 | public function getEntry($tableName, $id, array $options = []) |
|
79 | |||
80 | /** |
||
81 | * @inheritdoc |
||
82 | */ |
||
83 | 2 | public function getUsers(array $params = []) |
|
87 | |||
88 | /** |
||
89 | * @inheritdoc |
||
90 | */ |
||
91 | 2 | public function getUser($id, array $params = []) |
|
95 | |||
96 | /** |
||
97 | * @inheritdoc |
||
98 | */ |
||
99 | 2 | public function getGroups() |
|
103 | |||
104 | /** |
||
105 | * @inheritdoc |
||
106 | */ |
||
107 | 2 | public function getGroup($groupID) |
|
113 | |||
114 | /** |
||
115 | * @inheritdoc |
||
116 | */ |
||
117 | 2 | public function getGroupPrivileges($groupID) |
|
123 | |||
124 | /** |
||
125 | * @inheritdoc |
||
126 | */ |
||
127 | 2 | public function getFiles() |
|
131 | |||
132 | /** |
||
133 | * @inheritdoc |
||
134 | */ |
||
135 | 2 | public function getFile($fileID) |
|
141 | |||
142 | /** |
||
143 | * @inheritdoc |
||
144 | */ |
||
145 | 2 | public function getSettings() |
|
149 | |||
150 | /** |
||
151 | * @inheritdoc |
||
152 | */ |
||
153 | 2 | public function getSettingsByCollection($collectionName) |
|
159 | |||
160 | /** |
||
161 | * @inheritdoc |
||
162 | */ |
||
163 | public function getMessages($userId) |
||
169 | |||
170 | /** |
||
171 | * @inheritdoc |
||
172 | */ |
||
173 | public function createEntry($tableName, array $data) |
||
179 | |||
180 | /** |
||
181 | * @inheritdoc |
||
182 | */ |
||
183 | public function updateEntry($tableName, $id, array $data) |
||
189 | |||
190 | /** |
||
191 | * @inheritdoc |
||
192 | */ |
||
193 | public function deleteEntry($tableName, $id) |
||
199 | |||
200 | /** |
||
201 | * @inheritdoc |
||
202 | */ |
||
203 | View Code Duplication | public function createUser(array $data) |
|
213 | |||
214 | /** |
||
215 | * @inheritdoc |
||
216 | */ |
||
217 | View Code Duplication | public function updateUser($id, array $data) |
|
227 | |||
228 | /** |
||
229 | * @inheritdoc |
||
230 | */ |
||
231 | public function deleteUser($ids) |
||
235 | |||
236 | /** |
||
237 | * @inheritdoc |
||
238 | */ |
||
239 | public function createFile(array $data) |
||
271 | |||
272 | /** |
||
273 | * @inheritdoc |
||
274 | */ |
||
275 | public function updateFile($id, array $data) |
||
279 | |||
280 | /** |
||
281 | * @inheritdoc |
||
282 | */ |
||
283 | public function deleteFile($id) |
||
287 | } |
||
288 |