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:
Complex classes like Dropbox often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Dropbox, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
27 | class Dropbox |
||
28 | { |
||
29 | /** |
||
30 | * Uploading a file with the 'uploadFile' method, with the file's |
||
31 | * size less than this value (~8 MB), the simple `upload` method will be |
||
32 | * used, if the file size exceed this value (~8 MB), the `startUploadSession`, |
||
33 | * `appendUploadSession` & `finishUploadSession` methods will be used |
||
34 | * to upload the file in chunks. |
||
35 | * |
||
36 | * @const int |
||
37 | */ |
||
38 | const AUTO_CHUNKED_UPLOAD_THRESHOLD = 8000000; |
||
39 | |||
40 | /** |
||
41 | * The Chunk Size the file will be |
||
42 | * split into and uploaded (~4 MB) |
||
43 | * |
||
44 | * @const int |
||
45 | */ |
||
46 | const DEFAULT_CHUNK_SIZE = 4000000; |
||
47 | |||
48 | /** |
||
49 | * Response header containing file metadata |
||
50 | * |
||
51 | * @const string |
||
52 | */ |
||
53 | const METADATA_HEADER = 'dropbox-api-result'; |
||
54 | |||
55 | /** |
||
56 | * Prefix for writable temporary file |
||
57 | * |
||
58 | * @const string |
||
59 | */ |
||
60 | const TMP_PREFIX = 'dropbox-temp-file'; |
||
61 | |||
62 | /** |
||
63 | * The Dropbox App |
||
64 | * |
||
65 | * @var \Kunnu\Dropbox\DropboxApp |
||
66 | */ |
||
67 | protected $app; |
||
68 | |||
69 | /** |
||
70 | * OAuth2 Access Token |
||
71 | * |
||
72 | * @var string |
||
73 | */ |
||
74 | protected $accessToken; |
||
75 | |||
76 | /** |
||
77 | * Dropbox Client |
||
78 | * |
||
79 | * @var \Kunnu\Dropbox\DropboxClient |
||
80 | */ |
||
81 | protected $client; |
||
82 | |||
83 | /** |
||
84 | * OAuth2 Client |
||
85 | * |
||
86 | * @var \Kunnu\Dropbox\Authentication\OAuth2Client |
||
87 | */ |
||
88 | protected $oAuth2Client; |
||
89 | |||
90 | /** |
||
91 | * Random String Generator |
||
92 | * |
||
93 | * @var \Kunnu\Dropbox\Security\RandomStringGeneratorInterface |
||
94 | */ |
||
95 | protected $randomStringGenerator; |
||
96 | |||
97 | /** |
||
98 | * Persistent Data Store |
||
99 | * |
||
100 | * @var \Kunnu\Dropbox\Store\PersistentDataStoreInterface |
||
101 | */ |
||
102 | protected $persistentDataStore; |
||
103 | |||
104 | /** |
||
105 | * Create a new Dropbox instance |
||
106 | * |
||
107 | * @param \Kunnu\Dropbox\DropboxApp |
||
108 | * @param array $config Configuration Array |
||
109 | */ |
||
110 | public function __construct(DropboxApp $app, array $config = []) |
||
137 | |||
138 | /** |
||
139 | * Get Dropbox Auth Helper |
||
140 | * |
||
141 | * @return \Kunnu\Dropbox\Authentication\DropboxAuthHelper |
||
142 | */ |
||
143 | public function getAuthHelper() |
||
151 | |||
152 | /** |
||
153 | * Get OAuth2Client |
||
154 | * |
||
155 | * @return \Kunnu\Dropbox\Authentication\OAuth2Client |
||
156 | */ |
||
157 | public function getOAuth2Client() |
||
169 | |||
170 | /** |
||
171 | * Get the Dropbox App. |
||
172 | * |
||
173 | * @return \Kunnu\Dropbox\DropboxApp Dropbox App |
||
174 | */ |
||
175 | public function getApp() |
||
179 | |||
180 | /** |
||
181 | * Get the Client |
||
182 | * |
||
183 | * @return \Kunnu\Dropbox\DropboxClient |
||
184 | */ |
||
185 | public function getClient() |
||
189 | |||
190 | /** |
||
191 | * Get the Random String Generator |
||
192 | * |
||
193 | * @return \Kunnu\Dropbox\Security\RandomStringGeneratorInterface |
||
194 | */ |
||
195 | public function getRandomStringGenerator() |
||
199 | |||
200 | /** |
||
201 | * Get Persistent Data Store |
||
202 | * |
||
203 | * @return \Kunnu\Dropbox\Store\PersistentDataStoreInterface |
||
204 | */ |
||
205 | public function getPersistentDataStore() |
||
209 | |||
210 | /** |
||
211 | * Get the Metadata for a file or folder |
||
212 | * |
||
213 | * @param string $path Path of the file or folder |
||
214 | * @param array $params Additional Params |
||
215 | * |
||
216 | * @return \Kunnu\Dropbox\Models\FileMetadata | \Kunnu\Dropbox\Models\FolderMetadata |
||
217 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
218 | * |
||
219 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata |
||
220 | * |
||
221 | */ |
||
222 | public function getMetadata($path, array $params = []) |
||
238 | |||
239 | /** |
||
240 | * Make a HTTP POST Request to the API endpoint type |
||
241 | * |
||
242 | * @param string $endpoint API Endpoint to send Request to |
||
243 | * @param array $params Request Query Params |
||
244 | * @param string $accessToken Access Token to send with the Request |
||
245 | * |
||
246 | * @return \Kunnu\Dropbox\DropboxResponse |
||
247 | */ |
||
248 | public function postToAPI($endpoint, array $params = [], $accessToken = null) |
||
252 | |||
253 | /** |
||
254 | * Make Request to the API |
||
255 | * |
||
256 | * @param string $method HTTP Request Method |
||
257 | * @param string $endpoint API Endpoint to send Request to |
||
258 | * @param string $endpointType Endpoint type ['api'|'content'] |
||
259 | * @param array $params Request Query Params |
||
260 | * @param string $accessToken Access Token to send with the Request |
||
261 | * @param DropboxFile $responseFile Save response to the file |
||
262 | * |
||
263 | * @return \Kunnu\Dropbox\DropboxResponse |
||
264 | * |
||
265 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
266 | */ |
||
267 | public function sendRequest( |
||
288 | |||
289 | /** |
||
290 | * Get the Access Token. |
||
291 | * |
||
292 | * @return string Access Token |
||
293 | */ |
||
294 | public function getAccessToken() |
||
298 | |||
299 | /** |
||
300 | * Set the Access Token. |
||
301 | * |
||
302 | * @param string $accessToken Access Token |
||
303 | * |
||
304 | * @return \Kunnu\Dropbox\Dropbox Dropbox Client |
||
305 | */ |
||
306 | public function setAccessToken($accessToken) |
||
312 | |||
313 | /** |
||
314 | * Make Model from DropboxResponse |
||
315 | * |
||
316 | * @param DropboxResponse $response |
||
317 | * |
||
318 | * @return \Kunnu\Dropbox\Models\ModelInterface |
||
319 | * |
||
320 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
321 | */ |
||
322 | public function makeModelFromResponse(DropboxResponse $response) |
||
334 | |||
335 | /** |
||
336 | * Get the contents of a Folder |
||
337 | * |
||
338 | * @param string $path Path to the folder. Defaults to root. |
||
339 | * @param array $params Additional Params |
||
340 | * |
||
341 | * @return \Kunnu\Dropbox\Models\MetadataCollection |
||
342 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder |
||
343 | * |
||
344 | */ |
||
345 | View Code Duplication | public function listFolder($path = null, array $params = []) |
|
362 | |||
363 | /** |
||
364 | * Paginate through all files and retrieve updates to the folder, |
||
365 | * using the cursor retrieved from listFolder or listFolderContinue |
||
366 | * |
||
367 | * @param string $cursor The cursor returned by your |
||
368 | * last call to listFolder or listFolderContinue |
||
369 | * |
||
370 | * @return \Kunnu\Dropbox\Models\MetadataCollection |
||
371 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-continue |
||
372 | * |
||
373 | */ |
||
374 | public function listFolderContinue($cursor) |
||
381 | |||
382 | /** |
||
383 | * Get a cursor for the folder's state. |
||
384 | * |
||
385 | * @param string $path Path to the folder. Defaults to root. |
||
386 | * @param array $params Additional Params |
||
387 | * |
||
388 | * @return string The Cursor for the folder's state |
||
389 | * |
||
390 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
391 | * |
||
392 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-get_latest_cursor |
||
393 | * |
||
394 | */ |
||
395 | public function listFolderLatestCursor($path, array $params = []) |
||
421 | |||
422 | /** |
||
423 | * Get Revisions of a File |
||
424 | * |
||
425 | * @param string $path Path to the file |
||
426 | * @param array $params Additional Params |
||
427 | * |
||
428 | * @return \Kunnu\Dropbox\Models\ModelCollection |
||
429 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-list_revisions |
||
430 | * |
||
431 | */ |
||
432 | public function listRevisions($path, array $params = []) |
||
456 | |||
457 | /** |
||
458 | * Search a folder for files/folders |
||
459 | * |
||
460 | * @param string $path Path to search |
||
461 | * @param string $query Search Query |
||
462 | * @param array $params Additional Params |
||
463 | * |
||
464 | * @return \Kunnu\Dropbox\Models\SearchResults |
||
465 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-search |
||
466 | * |
||
467 | */ |
||
468 | View Code Duplication | public function search($path, $query, array $params = []) |
|
486 | |||
487 | /** |
||
488 | * Create a folder at the given path |
||
489 | * |
||
490 | * @param string $path Path to create |
||
491 | * @param boolean $autorename Auto Rename File |
||
492 | * |
||
493 | * @return \Kunnu\Dropbox\Models\FolderMetadata |
||
494 | * |
||
495 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
496 | * |
||
497 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-create_folder |
||
498 | * |
||
499 | */ |
||
500 | View Code Duplication | public function createFolder($path, $autorename = false) |
|
516 | |||
517 | /** |
||
518 | * Delete a file or folder at the given path |
||
519 | * |
||
520 | * @param string $path Path to file/folder to delete |
||
521 | * |
||
522 | * @return \Kunnu\Dropbox\Models\DeletedMetadata |
||
523 | * |
||
524 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
525 | * |
||
526 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-delete |
||
527 | * |
||
528 | */ |
||
529 | View Code Duplication | public function delete($path) |
|
547 | |||
548 | /** |
||
549 | * Move a file or folder to a different location |
||
550 | * |
||
551 | * @param string $fromPath Path to be moved |
||
552 | * @param string $toPath Path to be moved to |
||
553 | * |
||
554 | * @return \Kunnu\Dropbox\Models\DeletedMetadata|\Kunnu\Dropbox\Models\FileMetadata |
||
555 | * |
||
556 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
557 | * |
||
558 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-move |
||
559 | * |
||
560 | */ |
||
561 | View Code Duplication | public function move($fromPath, $toPath) |
|
574 | |||
575 | /** |
||
576 | * Copy a file or folder to a different location |
||
577 | * |
||
578 | * @param string $fromPath Path to be copied |
||
579 | * @param string $toPath Path to be copied to |
||
580 | * |
||
581 | * @return \Kunnu\Dropbox\Models\DeletedMetadata|\Kunnu\Dropbox\Models\FileMetadata |
||
582 | * |
||
583 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
584 | * |
||
585 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-copy |
||
586 | * |
||
587 | */ |
||
588 | View Code Duplication | public function copy($fromPath, $toPath) |
|
601 | |||
602 | /** |
||
603 | * Restore a file to the specific version |
||
604 | * |
||
605 | * @param string $path Path to the file to restore |
||
606 | * @param string $rev Revision to store for the file |
||
607 | * |
||
608 | * @return \Kunnu\Dropbox\Models\DeletedMetadata|\Kunnu\Dropbox\Models\FileMetadata|\Kunnu\Dropbox\Models\FolderMetadata |
||
609 | * |
||
610 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
611 | * |
||
612 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-restore |
||
613 | * |
||
614 | */ |
||
615 | View Code Duplication | public function restore($path, $rev) |
|
631 | |||
632 | /** |
||
633 | * Get Copy Reference |
||
634 | * |
||
635 | * @param string $path Path to the file or folder to get a copy reference to |
||
636 | * |
||
637 | * @return \Kunnu\Dropbox\Models\CopyReference |
||
638 | * |
||
639 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
640 | * |
||
641 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-get |
||
642 | * |
||
643 | */ |
||
644 | View Code Duplication | public function getCopyReference($path) |
|
658 | |||
659 | /** |
||
660 | * Save Copy Reference |
||
661 | * |
||
662 | * @param string $path Path to the file or folder to get a copy reference to |
||
663 | * @param string $copyReference Copy reference returned by getCopyReference |
||
664 | * |
||
665 | * @return \Kunnu\Dropbox\Models\FileMetadata|\Kunnu\Dropbox\Models\FolderMetadata |
||
666 | * |
||
667 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
668 | * |
||
669 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-save |
||
670 | * |
||
671 | */ |
||
672 | public function saveCopyReference($path, $copyReference) |
||
692 | |||
693 | /** |
||
694 | * Get a temporary link to stream contents of a file |
||
695 | * |
||
696 | * @param string $path Path to the file you want a temporary link to |
||
697 | * |
||
698 | * https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_link |
||
699 | * |
||
700 | * @return \Kunnu\Dropbox\Models\TemporaryLink |
||
701 | * |
||
702 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
703 | */ |
||
704 | View Code Duplication | public function getTemporaryLink($path) |
|
717 | |||
718 | /** |
||
719 | * Save a specified URL into a file in user's Dropbox |
||
720 | * |
||
721 | * @param string $path Path where the URL will be saved |
||
722 | * @param string $url URL to be saved |
||
723 | * |
||
724 | * @return string Async Job ID |
||
725 | * |
||
726 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
727 | * |
||
728 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-save_url |
||
729 | * |
||
730 | */ |
||
731 | View Code Duplication | public function saveUrl($path, $url) |
|
749 | |||
750 | /** |
||
751 | * Save a specified URL into a file in user's Dropbox |
||
752 | * |
||
753 | * @param $asyncJobId |
||
754 | * |
||
755 | * @return \Kunnu\Dropbox\Models\FileMetadata|string Status (failed|in_progress) or FileMetadata (if complete) |
||
756 | * |
||
757 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
758 | * |
||
759 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-save_url-check_job_status |
||
760 | * |
||
761 | */ |
||
762 | public function checkJobStatus($asyncJobId) |
||
784 | |||
785 | /** |
||
786 | * Upload a File to Dropbox |
||
787 | * |
||
788 | * @param string|DropboxFile $dropboxFile DropboxFile object or Path to file |
||
789 | * @param string $path Path to upload the file to |
||
790 | * @param array $params Additional Params |
||
791 | * |
||
792 | * @return \Kunnu\Dropbox\Models\FileMetadata |
||
793 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-upload |
||
794 | * |
||
795 | */ |
||
796 | public function upload($dropboxFile, $path, array $params = []) |
||
810 | |||
811 | |||
812 | /** |
||
813 | * Make DropboxFile Object using the given $data string as the file contents. |
||
814 | * @param $path |
||
815 | * @param $data |
||
816 | * @return DropboxFile |
||
817 | * @throws DropboxClientException |
||
818 | * @throws DropboxClientUnableToWriteToTempException |
||
819 | */ |
||
820 | public function makeDropboxFileFromString($path, $data) |
||
839 | |||
840 | /** |
||
841 | * Make DropboxFile Object |
||
842 | * |
||
843 | * @param string|DropboxFile $dropboxFile DropboxFile object or Path to file |
||
844 | * @param int $maxLength Max Bytes to read from the file |
||
845 | * @param int $offset Seek to specified offset before reading |
||
846 | * @param string $mode The type of access |
||
847 | * |
||
848 | * @return \Kunnu\Dropbox\DropboxFile |
||
849 | */ |
||
850 | public function makeDropboxFile($dropboxFile, $maxLength = null, $offset = null, $mode = DropboxFile::MODE_READ) |
||
873 | |||
874 | /** |
||
875 | * Upload file in sessions/chunks |
||
876 | * |
||
877 | * @param string|DropboxFile $dropboxFile DropboxFile object or Path to file |
||
878 | * @param string $path Path to save the file to, on Dropbox |
||
879 | * @param int $fileSize The size of the file |
||
880 | * @param int $chunkSize The amount of data to upload in each chunk |
||
881 | * @param array $params Additional Params |
||
882 | * |
||
883 | * @return \Kunnu\Dropbox\Models\FileMetadata |
||
884 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish |
||
885 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-append_v2 |
||
886 | * |
||
887 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start |
||
888 | */ |
||
889 | public function uploadChunked($dropboxFile, $path, $fileSize = null, $chunkSize = null, array $params = array()) |
||
938 | |||
939 | /** |
||
940 | * Start an Upload Session |
||
941 | * |
||
942 | * @param string|DropboxFile $dropboxFile DropboxFile object or Path to file |
||
943 | * @param int $chunkSize Size of file chunk to upload |
||
944 | * @param boolean $close Closes the session for "appendUploadSession" |
||
945 | * |
||
946 | * @return string Unique identifier for the upload session |
||
947 | * |
||
948 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
949 | * |
||
950 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start |
||
951 | * |
||
952 | */ |
||
953 | public function startUploadSession($dropboxFile, $chunkSize = -1, $close = false) |
||
976 | |||
977 | /** |
||
978 | * Make a HTTP POST Request to the Content endpoint type |
||
979 | * |
||
980 | * @param string $endpoint Content Endpoint to send Request to |
||
981 | * @param array $params Request Query Params |
||
982 | * @param string $accessToken Access Token to send with the Request |
||
983 | * @param DropboxFile $responseFile Save response to the file |
||
984 | * |
||
985 | * @return \Kunnu\Dropbox\DropboxResponse |
||
986 | */ |
||
987 | public function postToContent($endpoint, array $params = [], $accessToken = null, DropboxFile $responseFile = null) |
||
991 | |||
992 | /** |
||
993 | * Append more data to an Upload Session |
||
994 | * |
||
995 | * @param string|DropboxFile $dropboxFile DropboxFile object or Path to file |
||
996 | * @param string $sessionId Session ID returned by `startUploadSession` |
||
997 | * @param int $offset The amount of data that has been uploaded so far |
||
998 | * @param int $chunkSize The amount of data to upload |
||
999 | * @param boolean $close Closes the session for futher "appendUploadSession" calls |
||
1000 | * |
||
1001 | * @return string Unique identifier for the upload session |
||
1002 | * |
||
1003 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
1004 | * |
||
1005 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-append_v2 |
||
1006 | * |
||
1007 | */ |
||
1008 | public function appendUploadSession($dropboxFile, $sessionId, $offset, $chunkSize, $close = false) |
||
1040 | |||
1041 | /** |
||
1042 | * Finish an upload session and save the uploaded data to the given file path |
||
1043 | * |
||
1044 | * @param string|DropboxFile $dropboxFile DropboxFile object or Path to file |
||
1045 | * @param string $sessionId Session ID returned by `startUploadSession` |
||
1046 | * @param int $offset The amount of data that has been uploaded so far |
||
1047 | * @param int $remaining The amount of data that is remaining |
||
1048 | * @param string $path Path to save the file to, on Dropbox |
||
1049 | * @param array $params Additional Params |
||
1050 | * |
||
1051 | * @return \Kunnu\Dropbox\Models\FileMetadata |
||
1052 | * |
||
1053 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
1054 | * |
||
1055 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish |
||
1056 | * |
||
1057 | */ |
||
1058 | public function finishUploadSession($dropboxFile, $sessionId, $offset, $remaining, $path, array $params = []) |
||
1088 | |||
1089 | /** |
||
1090 | * Upload a File to Dropbox in a single request |
||
1091 | * |
||
1092 | * @param string|DropboxFile $dropboxFile DropboxFile object or Path to file |
||
1093 | * @param string $path Path to upload the file to |
||
1094 | * @param array $params Additional Params |
||
1095 | * |
||
1096 | * @return \Kunnu\Dropbox\Models\FileMetadata |
||
1097 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-upload |
||
1098 | * |
||
1099 | */ |
||
1100 | public function simpleUpload($dropboxFile, $path, array $params = []) |
||
1116 | |||
1117 | /** |
||
1118 | * Get a thumbnail for an image |
||
1119 | * |
||
1120 | * @param string $path Path to the file you want a thumbnail to |
||
1121 | * @param string $size Size for the thumbnail image ['thumb','small','medium','large','huge'] |
||
1122 | * @param string $format Format for the thumbnail image ['jpeg'|'png'] |
||
1123 | * |
||
1124 | * @return \Kunnu\Dropbox\Models\Thumbnail |
||
1125 | * |
||
1126 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
1127 | * |
||
1128 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail |
||
1129 | * |
||
1130 | */ |
||
1131 | public function getThumbnail($path, $size = 'small', $format = 'jpeg') |
||
1159 | |||
1160 | /** |
||
1161 | * Get thumbnail size |
||
1162 | * |
||
1163 | * @param string $size Thumbnail Size |
||
1164 | * |
||
1165 | * @return string |
||
1166 | */ |
||
1167 | protected function getThumbnailSize($size) |
||
1179 | |||
1180 | /** |
||
1181 | * Get metadata from response headers |
||
1182 | * |
||
1183 | * @param DropboxResponse $response |
||
1184 | * |
||
1185 | * @return array |
||
1186 | */ |
||
1187 | protected function getMetadataFromResponseHeaders(DropboxResponse $response) |
||
1215 | |||
1216 | /** |
||
1217 | * Download a File |
||
1218 | * |
||
1219 | * @param string $path Path to the file you want to download |
||
1220 | * @param null|string|DropboxFile $dropboxFile DropboxFile object or Path to target file |
||
1221 | * |
||
1222 | * @return \Kunnu\Dropbox\Models\File |
||
1223 | * |
||
1224 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
1225 | * |
||
1226 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-download |
||
1227 | * |
||
1228 | */ |
||
1229 | View Code Duplication | public function download($path, $dropboxFile = null) |
|
1251 | |||
1252 | /** |
||
1253 | * Download a folder as a zip file |
||
1254 | * |
||
1255 | * @param string $path Path to the file you want to download |
||
1256 | * @param null|string|DropboxFile $dropboxFile DropboxFile object or Path to target file |
||
1257 | * |
||
1258 | * @return \Kunnu\Dropbox\Models\File |
||
1259 | * |
||
1260 | * @throws \Kunnu\Dropbox\Exceptions\DropboxClientException |
||
1261 | * |
||
1262 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-download_zip |
||
1263 | * |
||
1264 | */ |
||
1265 | View Code Duplication | public function downloadZip($path, $dropboxFile = null) |
|
1287 | |||
1288 | /** |
||
1289 | * Get Current Account |
||
1290 | * |
||
1291 | * @link https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account |
||
1292 | * |
||
1293 | * @return \Kunnu\Dropbox\Models\Account |
||
1294 | */ |
||
1295 | public function getCurrentAccount() |
||
1304 | |||
1305 | /** |
||
1306 | * Get Account |
||
1307 | * |
||
1308 | * @param string $account_id Account ID of the account to get details for |
||
1309 | * |
||
1310 | * @return \Kunnu\Dropbox\Models\Account |
||
1311 | * @link https://www.dropbox.com/developers/documentation/http/documentation#users-get_account |
||
1312 | * |
||
1313 | */ |
||
1314 | public function getAccount($account_id) |
||
1323 | |||
1324 | /** |
||
1325 | * Get Multiple Accounts in one call |
||
1326 | * |
||
1327 | * @param array $account_ids IDs of the accounts to get details for |
||
1328 | * |
||
1329 | * @return \Kunnu\Dropbox\Models\AccountList |
||
1330 | * @link https://www.dropbox.com/developers/documentation/http/documentation#users-get_account_batch |
||
1331 | * |
||
1332 | */ |
||
1333 | public function getAccounts(array $account_ids = []) |
||
1342 | |||
1343 | /** |
||
1344 | * Get Space Usage for the current user's account |
||
1345 | * |
||
1346 | * @link https://www.dropbox.com/developers/documentation/http/documentation#users-get_space_usage |
||
1347 | * |
||
1348 | * @return array |
||
1349 | */ |
||
1350 | public function getSpaceUsage() |
||
1359 | } |
||
1360 |
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.