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 |
||
12 | class DropboxAdapter extends AbstractAdapter |
||
13 | { |
||
14 | use NotSupportingVisibilityTrait, ParseResponse; |
||
15 | |||
16 | /** @var \Srmklive\Dropbox\Client\DropboxClient */ |
||
17 | protected $client; |
||
18 | |||
19 | 19 | public function __construct(DropboxClient $client, $prefix = '') |
|
25 | |||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | 1 | public function write($path, $contents, Config $config) |
|
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | 1 | public function writeStream($path, $resource, Config $config) |
|
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | 1 | public function update($path, $contents, Config $config) |
|
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | 1 | public function updateStream($path, $resource, Config $config) |
|
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | 2 | public function rename($path, $newPath) |
|
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | 2 | View Code Duplication | public function copy($path, $newpath) |
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | 1 | public function delete($path) |
|
110 | |||
111 | /** |
||
112 | * {@inheritdoc} |
||
113 | */ |
||
114 | 1 | public function deleteDir($dirname) |
|
118 | |||
119 | /** |
||
120 | * {@inheritdoc} |
||
121 | */ |
||
122 | 1 | View Code Duplication | public function createDir($dirname, Config $config) |
136 | |||
137 | /** |
||
138 | * {@inheritdoc} |
||
139 | */ |
||
140 | 2 | public function has($path) |
|
144 | |||
145 | /** |
||
146 | * {@inheritdoc} |
||
147 | */ |
||
148 | 1 | public function read($path) |
|
163 | |||
164 | /** |
||
165 | * {@inheritdoc} |
||
166 | */ |
||
167 | 2 | public function readStream($path) |
|
181 | |||
182 | /** |
||
183 | * {@inheritdoc} |
||
184 | */ |
||
185 | 1 | public function listContents($directory = '', $recursive = false) |
|
202 | |||
203 | /** |
||
204 | * {@inheritdoc} |
||
205 | */ |
||
206 | 5 | View Code Duplication | public function getMetadata($path) |
218 | |||
219 | /** |
||
220 | * {@inheritdoc} |
||
221 | */ |
||
222 | 1 | public function getSize($path) |
|
226 | |||
227 | /** |
||
228 | * {@inheritdoc} |
||
229 | */ |
||
230 | public function getMimetype($path) |
||
234 | |||
235 | /** |
||
236 | * {@inheritdoc} |
||
237 | */ |
||
238 | 1 | public function getTimestamp($path) |
|
242 | |||
243 | /** |
||
244 | * {@inheritdoc} |
||
245 | */ |
||
246 | public function getTemporaryLink($path) |
||
250 | |||
251 | /** |
||
252 | * {@inheritdoc} |
||
253 | */ |
||
254 | public function getThumbnail($path, $format = 'jpeg', $size = 'w64h64') |
||
258 | |||
259 | /** |
||
260 | * {@inheritdoc} |
||
261 | */ |
||
262 | 18 | public function applyPathPrefix($path) |
|
268 | |||
269 | /** |
||
270 | * @return DropboxClient |
||
271 | */ |
||
272 | 1 | public function getClient() |
|
276 | |||
277 | /** |
||
278 | * @param string $path |
||
279 | * @param resource|string $contents |
||
280 | * @param string $mode |
||
281 | * |
||
282 | * @throws \Exception |
||
283 | * |
||
284 | * @return array|false file metadata |
||
285 | */ |
||
286 | 4 | View Code Duplication | protected function upload($path, $contents, $mode) |
299 | } |
||
300 |