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 | protected $baseEndpoint = 'http://localhost/api'; |
||
23 | 2 | protected $hostedBaseEndpointFormat = 'https://%s.directus.io/api'; |
|
24 | |||
25 | 2 | /** |
|
26 | * @inheritdoc |
||
27 | */ |
||
28 | 4 | public function getTables(array $params = []) |
|
32 | |||
33 | 2 | /** |
|
34 | * @inheritdoc |
||
35 | 2 | */ |
|
36 | public function getTable($tableName) |
||
40 | 2 | ||
41 | /** |
||
42 | * @inheritdoc |
||
43 | 2 | */ |
|
44 | public function getColumns($tableName, array $params = []) |
||
48 | 2 | ||
49 | /** |
||
50 | 2 | * @inheritdoc |
|
51 | */ |
||
52 | public function getColumn($tableName, $columnName) |
||
56 | |||
57 | /** |
||
58 | 2 | * @inheritdoc |
|
59 | */ |
||
60 | 2 | public function getEntries($tableName, array $options = []) |
|
64 | |||
65 | 2 | /** |
|
66 | * @inheritdoc |
||
67 | */ |
||
68 | 2 | public function getEntry($tableName, $id, array $options = []) |
|
72 | |||
73 | 2 | /** |
|
74 | * @inheritdoc |
||
75 | 2 | */ |
|
76 | public function getUsers(array $params = []) |
||
80 | 2 | ||
81 | /** |
||
82 | * @inheritdoc |
||
83 | 2 | */ |
|
84 | public function getUser($id, array $params = []) |
||
88 | 2 | ||
89 | /** |
||
90 | 2 | * @inheritdoc |
|
91 | */ |
||
92 | public function getGroups() |
||
96 | |||
97 | /** |
||
98 | 2 | * @inheritdoc |
|
99 | */ |
||
100 | 2 | public function getGroup($groupID) |
|
104 | |||
105 | /** |
||
106 | * @inheritdoc |
||
107 | */ |
||
108 | public function getGroupPrivileges($groupID) |
||
112 | |||
113 | /** |
||
114 | * @inheritdoc |
||
115 | */ |
||
116 | public function getFiles() |
||
120 | |||
121 | /** |
||
122 | * @inheritdoc |
||
123 | */ |
||
124 | public function getFile($fileID) |
||
128 | |||
129 | /** |
||
130 | * @inheritdoc |
||
131 | */ |
||
132 | public function getSettings() |
||
136 | |||
137 | /** |
||
138 | * @inheritdoc |
||
139 | */ |
||
140 | public function getSettingsByCollection($collectionName) |
||
144 | |||
145 | /** |
||
146 | * @inheritdoc |
||
147 | */ |
||
148 | public function getMessages($userId) |
||
152 | |||
153 | /** |
||
154 | * @inheritdoc |
||
155 | */ |
||
156 | public function createEntry($tableName, array $data) |
||
160 | |||
161 | /** |
||
162 | * @inheritdoc |
||
163 | */ |
||
164 | public function updateEntry($tableName, $id, array $data) |
||
168 | |||
169 | /** |
||
170 | * @inheritdoc |
||
171 | */ |
||
172 | public function deleteEntry($tableName, $ids) |
||
176 | |||
177 | /** |
||
178 | * @inheritdoc |
||
179 | */ |
||
180 | View Code Duplication | public function createUser(array $data) |
|
190 | |||
191 | /** |
||
192 | * @inheritdoc |
||
193 | */ |
||
194 | View Code Duplication | public function updateUser($id, array $data) |
|
204 | |||
205 | /** |
||
206 | * @inheritdoc |
||
207 | */ |
||
208 | public function deleteUser($ids) |
||
212 | |||
213 | /** |
||
214 | * @inheritdoc |
||
215 | */ |
||
216 | public function createFile(array $data) |
||
246 | |||
247 | /** |
||
248 | * @inheritdoc |
||
249 | */ |
||
250 | public function updateFile($id, array $data) |
||
254 | |||
255 | /** |
||
256 | * @inheritdoc |
||
257 | */ |
||
258 | public function deleteFile($ids) |
||
262 | } |
||
263 |