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 FileRestProxy 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 FileRestProxy, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
71 | class FileRestProxy extends ServiceRestProxy implements IFile |
||
72 | { |
||
73 | use ServiceRestTrait; |
||
74 | |||
75 | /** |
||
76 | * Creates URI path for file or share. |
||
77 | * |
||
78 | * @param string $share The share name. |
||
79 | * @param string $directory The directory name. |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | View Code Duplication | private function createPath($share, $directory = '') |
|
107 | |||
108 | /** |
||
109 | * Helper method to create promise for getShareProperties API call. |
||
110 | * |
||
111 | * @param string $share The share name. |
||
112 | * @param FileServiceOptions $options The optional parameters. |
||
113 | * @param string $operation The operation string. Should be |
||
114 | * 'metadata' to set metadata, |
||
115 | * and 'properties' to set |
||
116 | * properties. |
||
117 | * |
||
118 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
119 | */ |
||
120 | private function getSharePropertiesAsyncImpl( |
||
175 | |||
176 | /** |
||
177 | * Helper method to create promise for setShareProperties API call. |
||
178 | * |
||
179 | * @param string $share The share name. |
||
180 | * @param array $properties The array that contains |
||
181 | * either the properties or |
||
182 | * the metadata to be set. |
||
183 | * @param FileServiceOptions $options The optional parameters. |
||
184 | * @param string $operation The operation string. Should be |
||
185 | * 'metadata' to set metadata, |
||
186 | * and 'properties' to set |
||
187 | * properties. |
||
188 | * |
||
189 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
190 | */ |
||
191 | private function setSharePropertiesAsyncImpl( |
||
250 | |||
251 | /** |
||
252 | * Creates promise to write range of bytes (more than 4MB) to a file. |
||
253 | * |
||
254 | * @param string $share The share name. |
||
255 | * @param string $path The path of the file. |
||
256 | * @param StreamInterface $content The content to be uploaded. |
||
257 | * @param Range $range The range in the file to be put. |
||
258 | * 4MB length min. |
||
259 | * @param PutFileRangeOptions|null $options The optional parameters. |
||
260 | * |
||
261 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
262 | * |
||
263 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/put-range |
||
264 | * |
||
265 | */ |
||
266 | private function multiplePutRangeConcurrentAsync( |
||
360 | |||
361 | |||
362 | /** |
||
363 | * Returns a list of the shares under the specified account |
||
364 | * |
||
365 | * @param ListSharesOptions|null $options The optional parameters |
||
366 | * |
||
367 | * @return ListSharesResult |
||
368 | * |
||
369 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/list-shares |
||
370 | */ |
||
371 | public function listShares(ListSharesOptions $options = null) |
||
375 | |||
376 | /** |
||
377 | * Create a promise to return a list of the shares under the specified account |
||
378 | * |
||
379 | * @param ListSharesOptions|null $options The optional parameters |
||
380 | * |
||
381 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
382 | * |
||
383 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/list-shares |
||
384 | */ |
||
385 | public function listSharesAsync(ListSharesOptions $options = null) |
||
449 | |||
450 | /** |
||
451 | * Creates a new share in the given storage account. |
||
452 | * |
||
453 | * @param string $share The share name. |
||
454 | * @param CreateShareOptions|null $options The optional parameters. |
||
455 | * |
||
456 | * @return void |
||
457 | * |
||
458 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-share |
||
459 | */ |
||
460 | public function createShare( |
||
466 | |||
467 | /** |
||
468 | * Creates promise to create a new share in the given storage account. |
||
469 | * |
||
470 | * @param string $share The share name. |
||
471 | * @param CreateShareOptions|null $options The optional parameters. |
||
472 | * |
||
473 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
474 | * |
||
475 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-share |
||
476 | */ |
||
477 | View Code Duplication | public function createShareAsync( |
|
519 | |||
520 | /** |
||
521 | * Deletes a share in the given storage account. |
||
522 | * |
||
523 | * @param string $share name of the share |
||
524 | * @param FileServiceOptions|null $options optional parameters |
||
525 | * |
||
526 | * @return void |
||
527 | * |
||
528 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-share |
||
529 | */ |
||
530 | public function deleteShare( |
||
536 | |||
537 | /** |
||
538 | * Create a promise for deleting a share. |
||
539 | * |
||
540 | * @param string $share name of the share |
||
541 | * @param FileServiceOptions|null $options optional parameters |
||
542 | * |
||
543 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
544 | * |
||
545 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-share |
||
546 | */ |
||
547 | View Code Duplication | public function deleteShareAsync( |
|
587 | |||
588 | /** |
||
589 | * Returns all properties and metadata on the share. |
||
590 | * |
||
591 | * @param string $share name |
||
592 | * @param FileServiceOptions|null $options optional parameters |
||
593 | * |
||
594 | * @return GetSharePropertiesResult |
||
595 | * |
||
596 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-properties |
||
597 | */ |
||
598 | public function getShareProperties( |
||
604 | |||
605 | /** |
||
606 | * Create promise to return all properties and metadata on the share. |
||
607 | * |
||
608 | * @param string $share name |
||
609 | * @param FileServiceOptions|null $options optional parameters |
||
610 | * |
||
611 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
612 | * |
||
613 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-properties |
||
614 | */ |
||
615 | public function getSharePropertiesAsync( |
||
621 | |||
622 | /** |
||
623 | * Sets quota of the share. |
||
624 | * |
||
625 | * @param string $share name |
||
626 | * @param int $quota quota of the share |
||
627 | * @param FileServiceOptions|null $options optional parameters |
||
628 | * |
||
629 | * @return void |
||
630 | * |
||
631 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-properties |
||
632 | */ |
||
633 | public function setShareProperties( |
||
640 | |||
641 | /** |
||
642 | * Creates promise to set quota the share. |
||
643 | * |
||
644 | * @param string $share name |
||
645 | * @param int $quota quota of the share |
||
646 | * @param FileServiceOptions|null $options optional parameters |
||
647 | * |
||
648 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
649 | * |
||
650 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-properties |
||
651 | */ |
||
652 | public function setSharePropertiesAsync( |
||
664 | |||
665 | /** |
||
666 | * Returns only user-defined metadata for the specified share. |
||
667 | * |
||
668 | * @param string $share name |
||
669 | * @param FileServiceOptions|null $options optional parameters |
||
670 | * |
||
671 | * @return GetSharePropertiesResult |
||
672 | * |
||
673 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-metadata |
||
674 | */ |
||
675 | public function getShareMetadata( |
||
681 | |||
682 | /** |
||
683 | * Create promise to return only user-defined metadata for the specified |
||
684 | * share. |
||
685 | * |
||
686 | * @param string $share name |
||
687 | * @param FileServiceOptions|null $options optional parameters |
||
688 | * |
||
689 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
690 | * |
||
691 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-metadata |
||
692 | */ |
||
693 | public function getShareMetadataAsync( |
||
699 | |||
700 | /** |
||
701 | * Updates metadata of the share. |
||
702 | * |
||
703 | * @param string $share name |
||
704 | * @param array $metadata metadata key/value pair. |
||
705 | * @param FileServiceOptions|null $options optional parameters |
||
706 | * |
||
707 | * @return void |
||
708 | * |
||
709 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-metadata |
||
710 | */ |
||
711 | public function setShareMetadata( |
||
718 | |||
719 | /** |
||
720 | * Creates promise to update metadata headers on the share. |
||
721 | * |
||
722 | * @param string $share name |
||
723 | * @param array $metadata metadata key/value pair. |
||
724 | * @param FileServiceOptions|null $options optional parameters |
||
725 | * |
||
726 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
727 | * |
||
728 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-metadata |
||
729 | */ |
||
730 | public function setShareMetadataAsync( |
||
742 | |||
743 | /** |
||
744 | * Gets the access control list (ACL) for the share. |
||
745 | * |
||
746 | * @param string $share The share name. |
||
747 | * @param FileServiceOptions|null $options The optional parameters. |
||
748 | * |
||
749 | * @return GetShareACLResult |
||
750 | * |
||
751 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-acl |
||
752 | */ |
||
753 | public function getShareAcl( |
||
759 | |||
760 | /** |
||
761 | * Creates the promise to get the access control list (ACL) for the share. |
||
762 | * |
||
763 | * @param string $share The share name. |
||
764 | * @param FileServiceOptions|null $options The optional parameters. |
||
765 | * |
||
766 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
767 | * |
||
768 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-acl |
||
769 | */ |
||
770 | public function getShareAclAsync( |
||
834 | |||
835 | /** |
||
836 | * Sets the ACL and any share-level access policies for the share. |
||
837 | * |
||
838 | * @param string $share name |
||
839 | * @param ShareACL $acl access control list for share |
||
840 | * @param FileServiceOptions|null $options optional parameters |
||
841 | * |
||
842 | * @return void |
||
843 | * |
||
844 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-acl |
||
845 | */ |
||
846 | public function setShareAcl( |
||
853 | |||
854 | /** |
||
855 | * Creates promise to set the ACL and any share-level access policies |
||
856 | * for the share. |
||
857 | * |
||
858 | * @param string $share name |
||
859 | * @param ShareACL $acl access control list for share |
||
860 | * @param FileServiceOptions|null $options optional parameters |
||
861 | * |
||
862 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
863 | * |
||
864 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-share-acl |
||
865 | */ |
||
866 | View Code Duplication | public function setShareAclAsync( |
|
917 | |||
918 | /** |
||
919 | * Get the statistics related to the share. |
||
920 | * |
||
921 | * @param string $share The name of the share. |
||
922 | * @param FileServiceOptions|null $options The request options. |
||
923 | * |
||
924 | * @return GetShareStatsResult |
||
925 | * |
||
926 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-stats |
||
927 | */ |
||
928 | public function getShareStats($share, FileServiceOptions $options = null) |
||
932 | |||
933 | /** |
||
934 | * Get the statistics related to the share. |
||
935 | * |
||
936 | * @param string $share The name of the share. |
||
937 | * @param FileServiceOptions|null $options The request options. |
||
938 | * |
||
939 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
940 | * |
||
941 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-share-stats |
||
942 | */ |
||
943 | View Code Duplication | public function getShareStatsAsync($share, FileServiceOptions $options = null) |
|
991 | |||
992 | /** |
||
993 | * List directories and files under specified path. |
||
994 | * |
||
995 | * @param string $share The share that |
||
996 | * contains all the |
||
997 | * files and directories. |
||
998 | * @param string $path The path to be listed. |
||
999 | * @param ListDirectoriesAndFilesOptions|null $options Optional parameters. |
||
1000 | * |
||
1001 | * @return ListDirectoriesAndFilesResult |
||
1002 | * |
||
1003 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/list-directories-and-files |
||
1004 | */ |
||
1005 | public function listDirectoriesAndFiles( |
||
1012 | |||
1013 | /** |
||
1014 | * Creates promise to list directories and files under specified path. |
||
1015 | * |
||
1016 | * @param string $share The share that |
||
1017 | * contains all the |
||
1018 | * files and directories. |
||
1019 | * @param string $path The path to be listed. |
||
1020 | * @param ListDirectoriesAndFilesOptions|null $options Optional parameters. |
||
1021 | * |
||
1022 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
1023 | * |
||
1024 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/list-directories-and-files |
||
1025 | */ |
||
1026 | public function listDirectoriesAndFilesAsync( |
||
1096 | |||
1097 | /** |
||
1098 | * Creates a new directory in the given share and path. |
||
1099 | * |
||
1100 | * @param string $share The share name. |
||
1101 | * @param string $path The path to create the directory. |
||
1102 | * @param CreateDirectoryOptions|null $options The optional parameters. |
||
1103 | * |
||
1104 | * @return void |
||
1105 | * |
||
1106 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-directory |
||
1107 | */ |
||
1108 | public function createDirectory( |
||
1115 | |||
1116 | /** |
||
1117 | * Creates a promise to create a new directory in the given share and path. |
||
1118 | * |
||
1119 | * @param string $share The share name. |
||
1120 | * @param string $path The path to create the directory. |
||
1121 | * @param CreateDirectoryOptions|null $options The optional parameters. |
||
1122 | * |
||
1123 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
1124 | * |
||
1125 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-directory |
||
1126 | */ |
||
1127 | public function createDirectoryAsync( |
||
1166 | |||
1167 | /** |
||
1168 | * Deletes a directory in the given share and path. |
||
1169 | * |
||
1170 | * @param string $share The share name. |
||
1171 | * @param string $path The path to delete the directory. |
||
1172 | * @param FileServiceOptions|null $options The optional parameters. |
||
1173 | * |
||
1174 | * @return void |
||
1175 | * |
||
1176 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-directory |
||
1177 | */ |
||
1178 | public function deleteDirectory( |
||
1185 | |||
1186 | /** |
||
1187 | * Creates a promise to delete a new directory in the given share and path. |
||
1188 | * |
||
1189 | * @param string $share The share name. |
||
1190 | * @param string $path The path to delete the directory. |
||
1191 | * @param FileServiceOptions|null $options The optional parameters. |
||
1192 | * |
||
1193 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
1194 | * |
||
1195 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-directory |
||
1196 | */ |
||
1197 | View Code Duplication | public function deleteDirectoryAsync( |
|
1232 | |||
1233 | /** |
||
1234 | * Gets a directory's properties from the given share and path. |
||
1235 | * |
||
1236 | * @param string $share The share name. |
||
1237 | * @param string $path The path of the directory. |
||
1238 | * @param FileServiceOptions|null $options The optional parameters. |
||
1239 | * |
||
1240 | * @return GetDirectoryPropertiesResult |
||
1241 | * |
||
1242 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-directory-properties |
||
1243 | */ |
||
1244 | public function getDirectoryProperties( |
||
1251 | |||
1252 | /** |
||
1253 | * Creates promise to get a directory's properties from the given share |
||
1254 | * and path. |
||
1255 | * |
||
1256 | * @param string $share The share name. |
||
1257 | * @param string $path The path of the directory. |
||
1258 | * @param FileServiceOptions|null $options The optional parameters. |
||
1259 | * |
||
1260 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
1261 | * |
||
1262 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-directory-properties |
||
1263 | */ |
||
1264 | View Code Duplication | public function getDirectoryPropertiesAsync( |
|
1302 | |||
1303 | /** |
||
1304 | * Gets a directory's metadata from the given share and path. |
||
1305 | * |
||
1306 | * @param string $share The share name. |
||
1307 | * @param string $path The path of the directory. |
||
1308 | * @param FileServiceOptions|null $options The optional parameters. |
||
1309 | * |
||
1310 | * @return GetDirectoryMetadataResult |
||
1311 | * |
||
1312 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-directory-metadata |
||
1313 | */ |
||
1314 | public function getDirectoryMetadata( |
||
1321 | |||
1322 | /** |
||
1323 | * Creates promise to get a directory's metadata from the given share |
||
1324 | * and path. |
||
1325 | * |
||
1326 | * @param string $share The share name. |
||
1327 | * @param string $path The path of the directory. |
||
1328 | * @param FileServiceOptions|null $options The optional parameters. |
||
1329 | * |
||
1330 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
1331 | * |
||
1332 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-directory-metadata |
||
1333 | */ |
||
1334 | View Code Duplication | public function getDirectoryMetadataAsync( |
|
1378 | |||
1379 | /** |
||
1380 | * Sets a directory's metadata from the given share and path. |
||
1381 | * |
||
1382 | * @param string $share The share name. |
||
1383 | * @param string $path The path to delete the directory. |
||
1384 | * @param array $metadata The metadata to be set. |
||
1385 | * @param FileServiceOptions|null $options The optional parameters. |
||
1386 | * |
||
1387 | * @return void |
||
1388 | * |
||
1389 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-directory-metadata |
||
1390 | */ |
||
1391 | public function setDirectoryMetadata( |
||
1404 | |||
1405 | /** |
||
1406 | * Creates promise to set a directory's metadata from the given share |
||
1407 | * and path. |
||
1408 | * |
||
1409 | * @param string $share The share name. |
||
1410 | * @param string $path The path to delete the directory. |
||
1411 | * @param array $metadata The metadata to be set. |
||
1412 | * @param FileServiceOptions|null $options The optional parameters. |
||
1413 | * |
||
1414 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
1415 | * |
||
1416 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-directory-metadata |
||
1417 | */ |
||
1418 | View Code Duplication | public function setDirectoryMetadataAsync( |
|
1461 | |||
1462 | /** |
||
1463 | * Create a new file. |
||
1464 | * |
||
1465 | * @param string $share The share name. |
||
1466 | * @param string $path The path and name of the file. |
||
1467 | * @param int $size The size of the file. |
||
1468 | * @param CreateFileOptions|null $options The optional parameters. |
||
1469 | * |
||
1470 | * @return void |
||
1471 | * |
||
1472 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-file |
||
1473 | */ |
||
1474 | public function createFile( |
||
1487 | |||
1488 | /** |
||
1489 | * Creates promise to create a new file. |
||
1490 | * |
||
1491 | * @param string $share The share name. |
||
1492 | * @param string $path The path and name of the file. |
||
1493 | * @param int $size The size of the file. |
||
1494 | * @param CreateFileOptions|null $options The optional parameters. |
||
1495 | * |
||
1496 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
1497 | * |
||
1498 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-file |
||
1499 | */ |
||
1500 | public function createFileAsync( |
||
1596 | |||
1597 | /** |
||
1598 | * Deletes a file in the given share and path. |
||
1599 | * |
||
1600 | * @param string $share The share name. |
||
1601 | * @param string $path The path to delete the file. |
||
1602 | * @param FileServiceOptions|null $options The optional parameters. |
||
1603 | * |
||
1604 | * @return void |
||
1605 | * |
||
1606 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-file2 |
||
1607 | */ |
||
1608 | public function deleteFile( |
||
1615 | |||
1616 | /** |
||
1617 | * Creates a promise to delete a new file in the given share and path. |
||
1618 | * |
||
1619 | * @param string $share The share name. |
||
1620 | * @param string $path The path to delete the file. |
||
1621 | * @param FileServiceOptions|null $options The optional parameters. |
||
1622 | * |
||
1623 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
1624 | * |
||
1625 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-file2 |
||
1626 | */ |
||
1627 | View Code Duplication | public function deleteFileAsync( |
|
1662 | |||
1663 | /** |
||
1664 | * Reads or downloads a file from the server, including its metadata and |
||
1665 | * properties. |
||
1666 | * |
||
1667 | * @param string $share name of the share |
||
1668 | * @param string $path path of the file to be get |
||
1669 | * @param GetFileOptions|null $options optional parameters |
||
1670 | * |
||
1671 | * @return GetFileResult |
||
1672 | * |
||
1673 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-file |
||
1674 | */ |
||
1675 | public function getFile( |
||
1682 | |||
1683 | /** |
||
1684 | * Creates promise to read or download a file from the server, including its |
||
1685 | * metadata and properties. |
||
1686 | * |
||
1687 | * @param string $share name of the share |
||
1688 | * @param string $path path of the file to be get |
||
1689 | * @param GetFileOptions|null $options optional parameters |
||
1690 | * |
||
1691 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
1692 | * |
||
1693 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-file |
||
1694 | */ |
||
1695 | public function getFileAsync( |
||
1753 | |||
1754 | /** |
||
1755 | * Gets a file's properties from the given share and path. |
||
1756 | * |
||
1757 | * @param string $share The share name. |
||
1758 | * @param string $path The path to delete the file. |
||
1759 | * @param FileServiceOptions|null $options The optional parameters. |
||
1760 | * |
||
1761 | * @return FileProperties |
||
1762 | * |
||
1763 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-properties |
||
1764 | */ |
||
1765 | public function getFileProperties( |
||
1772 | |||
1773 | /** |
||
1774 | * Creates promise to get a file's properties from the given share |
||
1775 | * and path. |
||
1776 | * |
||
1777 | * @param string $share The share name. |
||
1778 | * @param string $path The path to delete the file. |
||
1779 | * @param FileServiceOptions|null $options The optional parameters. |
||
1780 | * |
||
1781 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
1782 | * |
||
1783 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-properties |
||
1784 | */ |
||
1785 | View Code Duplication | public function getFilePropertiesAsync( |
|
1823 | |||
1824 | /** |
||
1825 | * Sets properties on the file. |
||
1826 | * |
||
1827 | * @param string $share share name |
||
1828 | * @param string $path path of the file |
||
1829 | * @param FileProperties $properties file properties. |
||
1830 | * @param FileServiceOptions|null $options optional parameters |
||
1831 | * |
||
1832 | * @return void |
||
1833 | * |
||
1834 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-properties |
||
1835 | */ |
||
1836 | public function setFileProperties( |
||
1844 | |||
1845 | /** |
||
1846 | * Creates promise to set properties on the file. |
||
1847 | * |
||
1848 | * @param string $share share name |
||
1849 | * @param string $path path of the file |
||
1850 | * @param FileProperties $properties file properties. |
||
1851 | * @param FileServiceOptions|null $options optional parameters |
||
1852 | * |
||
1853 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
1854 | * |
||
1855 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-properties |
||
1856 | */ |
||
1857 | public function setFilePropertiesAsync( |
||
1936 | |||
1937 | /** |
||
1938 | * Gets a file's metadata from the given share and path. |
||
1939 | * |
||
1940 | * @param string $share The share name. |
||
1941 | * @param string $path The path of the file. |
||
1942 | * @param FileServiceOptions|null $options The optional parameters. |
||
1943 | * |
||
1944 | * @return GetFileMetadataResult |
||
1945 | * |
||
1946 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-metadata |
||
1947 | */ |
||
1948 | public function getFileMetadata( |
||
1955 | |||
1956 | /** |
||
1957 | * Creates promise to get a file's metadata from the given share |
||
1958 | * and path. |
||
1959 | * |
||
1960 | * @param string $share The share name. |
||
1961 | * @param string $path The path of the file. |
||
1962 | * @param FileServiceOptions|null $options The optional parameters. |
||
1963 | * |
||
1964 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
1965 | * |
||
1966 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-metadata |
||
1967 | */ |
||
1968 | View Code Duplication | public function getFileMetadataAsync( |
|
2012 | |||
2013 | /** |
||
2014 | * Sets a file's metadata from the given share and path. |
||
2015 | * |
||
2016 | * @param string $share The share name. |
||
2017 | * @param string $path The path to delete the file. |
||
2018 | * @param array $metadata The metadata to be set. |
||
2019 | * @param FileServiceOptions|null $options The optional parameters. |
||
2020 | * |
||
2021 | * @return void |
||
2022 | * |
||
2023 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-metadata |
||
2024 | */ |
||
2025 | public function setFileMetadata( |
||
2038 | |||
2039 | /** |
||
2040 | * Creates promise to set a file's metadata from the given share |
||
2041 | * and path. |
||
2042 | * |
||
2043 | * @param string $share The share name. |
||
2044 | * @param string $path The path to delete the file. |
||
2045 | * @param array $metadata The metadata to be set. |
||
2046 | * @param FileServiceOptions|null $options The optional parameters. |
||
2047 | * |
||
2048 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
2049 | * |
||
2050 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-file-metadata |
||
2051 | */ |
||
2052 | View Code Duplication | public function setFileMetadataAsync( |
|
2095 | |||
2096 | /** |
||
2097 | * Writes range of bytes to a file. Range can be at most 4MB in length. |
||
2098 | * |
||
2099 | * @param string $share The share name. |
||
2100 | * @param string $path The path of the file. |
||
2101 | * @param string|resource|StreamInterface $content The content to be uploaded. |
||
2102 | * @param Range $range The range in the file to |
||
2103 | * be put. |
||
2104 | * @param PutFileRangeOptions|null $options The optional parameters. |
||
2105 | * |
||
2106 | * @return void |
||
2107 | * |
||
2108 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/put-range |
||
2109 | */ |
||
2110 | public function putFileRange( |
||
2125 | |||
2126 | /** |
||
2127 | * Creates promise to write range of bytes to a file. Range can be at most |
||
2128 | * 4MB in length. |
||
2129 | * |
||
2130 | * @param string $share The share name. |
||
2131 | * @param string $path The path of the file. |
||
2132 | * @param string|resource|StreamInterface $content The content to be uploaded. |
||
2133 | * @param Range $range The range in the file to |
||
2134 | * be put. |
||
2135 | * @param PutFileRangeOptions|null $options The optional parameters. |
||
2136 | * |
||
2137 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
2138 | * |
||
2139 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/put-range |
||
2140 | * |
||
2141 | */ |
||
2142 | public function putFileRangeAsync( |
||
2213 | |||
2214 | /** |
||
2215 | * Creates a file from a provided content. |
||
2216 | * |
||
2217 | * @param string $share the share name |
||
2218 | * @param string $path the path of the file |
||
2219 | * @param StreamInterface|resource|string $content the content used to |
||
2220 | * create the file |
||
2221 | * @param CreateFileOptions|null $options optional parameters |
||
2222 | * |
||
2223 | * @return void |
||
2224 | */ |
||
2225 | public function createFileFromContent( |
||
2233 | |||
2234 | /** |
||
2235 | * Creates a promise to create a file from a provided content. |
||
2236 | * |
||
2237 | * @param string $share the share name |
||
2238 | * @param string $path the path of the file |
||
2239 | * @param StreamInterface|resource|string $content the content used to |
||
2240 | * create the file |
||
2241 | * @param CreateFileOptions|null $options optional parameters |
||
2242 | * |
||
2243 | * @return void |
||
2244 | */ |
||
2245 | public function createFileFromContentAsync( |
||
2298 | |||
2299 | /** |
||
2300 | * Clears range of bytes of a file. If the specified range is not 512-byte |
||
2301 | * aligned, the operation will write zeros to the start or end of the range |
||
2302 | * that is not 512-byte aligned and free the rest of the range inside that |
||
2303 | * is 512-byte aligned. |
||
2304 | * |
||
2305 | * @param string $share The share name. |
||
2306 | * @param string $path The path of the file. |
||
2307 | * @param Range $range The range in the file to |
||
2308 | * be cleared. |
||
2309 | * @param FileServiceOptions|null $options The optional parameters. |
||
2310 | * |
||
2311 | * @return void |
||
2312 | * |
||
2313 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/put-range |
||
2314 | */ |
||
2315 | public function clearFileRange( |
||
2323 | |||
2324 | /** |
||
2325 | * Creates promise to clear range of bytes of a file. If the specified range |
||
2326 | * is not 512-byte aligned, the operation will write zeros to the start or |
||
2327 | * end of the range that is not 512-byte aligned and free the rest of the |
||
2328 | * range inside that is 512-byte aligned. |
||
2329 | * |
||
2330 | * @param string $share The share name. |
||
2331 | * @param string $path The path of the file. |
||
2332 | * @param Range $range The range in the file to |
||
2333 | * be cleared. |
||
2334 | * @param FileServiceOptions|null $options The optional parameters. |
||
2335 | * |
||
2336 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
2337 | * |
||
2338 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/put-range |
||
2339 | * |
||
2340 | */ |
||
2341 | public function clearFileRangeAsync( |
||
2397 | |||
2398 | /** |
||
2399 | * Lists range of bytes of a file. |
||
2400 | * |
||
2401 | * @param string $share The share name. |
||
2402 | * @param string $path The path of the file. |
||
2403 | * @param Range $range The range in the file to |
||
2404 | * be listed. |
||
2405 | * @param FileServiceOptions|null $options The optional parameters. |
||
2406 | * |
||
2407 | * @return ListFileRangesResult |
||
2408 | * |
||
2409 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/list-ranges |
||
2410 | */ |
||
2411 | public function listFileRange( |
||
2419 | |||
2420 | /** |
||
2421 | * Creates promise to list range of bytes of a file. |
||
2422 | * |
||
2423 | * @param string $share The share name. |
||
2424 | * @param string $path The path of the file. |
||
2425 | * @param Range $range The range in the file to |
||
2426 | * be listed. |
||
2427 | * @param FileServiceOptions|null $options The optional parameters. |
||
2428 | * |
||
2429 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
2430 | * |
||
2431 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/list-ranges |
||
2432 | * |
||
2433 | */ |
||
2434 | public function listFileRangeAsync( |
||
2492 | |||
2493 | /** |
||
2494 | * Informs server to copy file from $sourcePath to $path. |
||
2495 | * To copy a file to another file within the same storage account, you may |
||
2496 | * use Shared Key to authenticate the source file. If you are copying a file |
||
2497 | * from another storage account, or if you are copying a blob from the same |
||
2498 | * storage account or another storage account, then you must authenticate |
||
2499 | * the source file or blob using a shared access signature. If the source is |
||
2500 | * a public blob, no authentication is required to perform the copy |
||
2501 | * operation. |
||
2502 | * Here are some examples of source object URLs: |
||
2503 | * https://myaccount.file.core.windows.net/myshare/mydirectorypath/myfile |
||
2504 | * https://myaccount.blob.core.windows.net/mycontainer/myblob?sastoken |
||
2505 | * |
||
2506 | * @param string $share The share name. |
||
2507 | * @param string $path The path of the file. |
||
2508 | * @param string $sourcePath The path of the source. |
||
2509 | * @param array $metadata The metadata of the file. |
||
2510 | * If specified, source metadata |
||
2511 | * will not be copied. |
||
2512 | * @param FileServiceOptions|null $options The optional parameters. |
||
2513 | * |
||
2514 | * @return CopyFileResult |
||
2515 | * |
||
2516 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/copy-file |
||
2517 | */ |
||
2518 | public function copyFile( |
||
2533 | |||
2534 | /** |
||
2535 | * Creates promise to inform server to copy file from $sourcePath to $path. |
||
2536 | * |
||
2537 | * To copy a file to another file within the same storage account, you may |
||
2538 | * use Shared Key to authenticate the source file. If you are copying a file |
||
2539 | * from another storage account, or if you are copying a blob from the same |
||
2540 | * storage account or another storage account, then you must authenticate |
||
2541 | * the source file or blob using a shared access signature. If the source is |
||
2542 | * a public blob, no authentication is required to perform the copy |
||
2543 | * operation. |
||
2544 | * Here are some examples of source object URLs: |
||
2545 | * https://myaccount.file.core.windows.net/myshare/mydirectorypath/myfile |
||
2546 | * https://myaccount.blob.core.windows.net/mycontainer/myblob?sastoken |
||
2547 | * |
||
2548 | * @param string $share The share name. |
||
2549 | * @param string $path The path of the file. |
||
2550 | * @param string $sourcePath The path of the source. |
||
2551 | * @param array $metadata The metadata of the file. |
||
2552 | * If specified, source metadata |
||
2553 | * will not be copied. |
||
2554 | * @param FileServiceOptions|null $options The optional parameters. |
||
2555 | * |
||
2556 | * @return \GuzzleHttp\Promise\PromiseInterface |
||
2557 | * |
||
2558 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/copy-file |
||
2559 | * |
||
2560 | */ |
||
2561 | public function copyFileAsync( |
||
2614 | |||
2615 | /** |
||
2616 | * Abort a file copy operation |
||
2617 | * |
||
2618 | * @param string $share name of the share |
||
2619 | * @param string $path path of the file |
||
2620 | * @param string $copyID copy operation identifier. |
||
2621 | * @param FileServiceOptions|null $options optional parameters |
||
2622 | * |
||
2623 | * @return void |
||
2624 | * |
||
2625 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/abort-copy-file |
||
2626 | */ |
||
2627 | public function abortCopy( |
||
2640 | |||
2641 | /** |
||
2642 | * Creates promise to abort a file copy operation |
||
2643 | * |
||
2644 | * @param string $share name of the share |
||
2645 | * @param string $path path of the file |
||
2646 | * @param string $copyID copy operation identifier. |
||
2647 | * @param FileServiceOptions|null $options optional parameters |
||
2648 | * |
||
2649 | * @return void |
||
2650 | * |
||
2651 | * @see https://docs.microsoft.com/en-us/rest/api/storageservices/abort-copy-file |
||
2652 | */ |
||
2653 | public function abortCopyAsync( |
||
2711 | } |
||
2712 |
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.