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 elFinderVolumeGoogleDrive 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 elFinderVolumeGoogleDrive, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
12 | class elFinderVolumeGoogleDrive extends elFinderVolumeDriver |
||
13 | { |
||
14 | /** |
||
15 | * MIME tyoe of directory. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | const DIRMIME = 'application/vnd.google-apps.folder'; |
||
20 | |||
21 | /** |
||
22 | * Fetch fields for list. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | const FETCHFIELDS_LIST = 'files(id,name,mimeType,modifiedTime,parents,permissions,size,imageMediaMetadata(height,width),thumbnailLink,webContentLink,webViewLink),nextPageToken'; |
||
27 | |||
28 | /** |
||
29 | * Fetch fields for get. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | const FETCHFIELDS_GET = 'id,name,mimeType,modifiedTime,parents,permissions,size,imageMediaMetadata(height,width),thumbnailLink,webContentLink,webViewLink'; |
||
34 | |||
35 | /** |
||
36 | * Net mount key. |
||
37 | * |
||
38 | * @var string |
||
39 | **/ |
||
40 | public $netMountKey = ''; |
||
41 | /** |
||
42 | * Driver id |
||
43 | * Must be started from letter and contains [a-z0-9] |
||
44 | * Used as part of volume id. |
||
45 | * |
||
46 | * @var string |
||
47 | **/ |
||
48 | protected $driverId = 'gd'; |
||
49 | |||
50 | /** |
||
51 | * Google API client object. |
||
52 | * |
||
53 | * @var object |
||
54 | **/ |
||
55 | protected $client = null; |
||
56 | |||
57 | /** |
||
58 | * GoogleDrive service object. |
||
59 | * |
||
60 | * @var object |
||
61 | **/ |
||
62 | protected $service = null; |
||
63 | |||
64 | /** |
||
65 | * Cache of parents of each directories. |
||
66 | * |
||
67 | * @var array |
||
68 | */ |
||
69 | protected $parents = []; |
||
70 | |||
71 | /** |
||
72 | * Cache of chiled directories of each directories. |
||
73 | * |
||
74 | * @var array |
||
75 | */ |
||
76 | protected $directories = null; |
||
77 | |||
78 | /** |
||
79 | * Cache of itemID => name of each items. |
||
80 | * |
||
81 | * @var array |
||
82 | */ |
||
83 | protected $names = []; |
||
84 | |||
85 | /** |
||
86 | * Directory for tmp files |
||
87 | * If not set driver will try to use tmbDir as tmpDir. |
||
88 | * |
||
89 | * @var string |
||
90 | **/ |
||
91 | protected $tmp = ''; |
||
92 | |||
93 | /** |
||
94 | * Constructor |
||
95 | * Extend options with required fields. |
||
96 | * |
||
97 | * @author Dmitry (dio) Levashov |
||
98 | * @author Cem (DiscoFever) |
||
99 | **/ |
||
100 | public function __construct() |
||
134 | |||
135 | /*********************************************************************/ |
||
136 | /* EXTENDED FUNCTIONS */ |
||
137 | /*********************************************************************/ |
||
138 | |||
139 | /** |
||
140 | * Prepare |
||
141 | * Call from elFinder::netmout() before volume->mount(). |
||
142 | * |
||
143 | * @return array |
||
144 | * |
||
145 | * @author Naoki Sawada |
||
146 | * @author Raja Sharma updating for GoogleDrive |
||
147 | **/ |
||
148 | public function netmountPrepare($options) |
||
325 | |||
326 | /** |
||
327 | * process of on netunmount |
||
328 | * Drop `googledrive` & rm thumbs. |
||
329 | * |
||
330 | * @param array $options |
||
331 | * |
||
332 | * @return bool |
||
333 | */ |
||
334 | public function netunmount($netVolumes, $key) |
||
347 | |||
348 | /*********************************************************************/ |
||
349 | /* FS API */ |
||
350 | /*********************************************************************/ |
||
351 | |||
352 | /** |
||
353 | * Close opened connection. |
||
354 | * |
||
355 | * @author Dmitry (dio) Levashov |
||
356 | **/ |
||
357 | public function umount() |
||
360 | |||
361 | /** |
||
362 | * Return content URL (for netmout volume driver) |
||
363 | * If file.url == 1 requests from JavaScript client with XHR. |
||
364 | * |
||
365 | * @param string $hash file hash |
||
366 | * @param array $options options array |
||
367 | * |
||
368 | * @return bool|string |
||
369 | * |
||
370 | * @author Naoki Sawada |
||
371 | */ |
||
372 | public function getContentUrl($hash, $options = []) |
||
393 | |||
394 | /** |
||
395 | * Return debug info for client. |
||
396 | * |
||
397 | * @return array |
||
398 | **/ |
||
399 | public function debug() |
||
408 | |||
409 | /*********************************************************************/ |
||
410 | /* ORIGINAL FUNCTIONS */ |
||
411 | /*********************************************************************/ |
||
412 | |||
413 | /** |
||
414 | * Get Parent ID, Item ID, Parent Path as an array from path. |
||
415 | * |
||
416 | * @param string $path |
||
417 | * |
||
418 | * @return array |
||
419 | */ |
||
420 | protected function _gd_splitPath($path) |
||
446 | |||
447 | /** |
||
448 | * Parse line from googledrive metadata output and return file stat (array). |
||
449 | * |
||
450 | * @param string $raw line from ftp_rawlist() output |
||
451 | * |
||
452 | * @return array |
||
453 | * |
||
454 | * @author Dmitry Levashov |
||
455 | **/ |
||
456 | protected function _gd_parseRaw($raw) |
||
500 | |||
501 | /** |
||
502 | * Make cache of $parents, $names and $directories. |
||
503 | * |
||
504 | * @param string $usecache |
||
505 | */ |
||
506 | protected function _gd_getDirectoryData($usecache = true) |
||
557 | |||
558 | /** |
||
559 | * Get descendants directories. |
||
560 | * |
||
561 | * @param string $itemId |
||
562 | * |
||
563 | * @return array |
||
564 | */ |
||
565 | protected function _gd_getDirectories($itemId) |
||
581 | |||
582 | /** |
||
583 | * Get ID based path from item ID. |
||
584 | * |
||
585 | * @param string $path |
||
586 | */ |
||
587 | protected function _gd_getMountPaths($id) |
||
615 | |||
616 | /** |
||
617 | * Return is published. |
||
618 | * |
||
619 | * @param object $file |
||
620 | * |
||
621 | * @return bool |
||
622 | */ |
||
623 | protected function _gd_isPublished($file) |
||
639 | |||
640 | /** |
||
641 | * return item URL link. |
||
642 | * |
||
643 | * @param object $file |
||
644 | * |
||
645 | * @return string |
||
646 | */ |
||
647 | protected function _gd_getLink($file) |
||
658 | |||
659 | /** |
||
660 | * Get download url. |
||
661 | * |
||
662 | * @param Google_Service_Drive_DriveFile $file |
||
663 | * |
||
664 | * @return string|false |
||
665 | */ |
||
666 | protected function _gd_getDownloadUrl($file) |
||
684 | |||
685 | /** |
||
686 | * Get thumbnail from GoogleDrive.com. |
||
687 | * |
||
688 | * @param string $path |
||
689 | * @param string $size |
||
690 | * |
||
691 | * @return string | boolean |
||
692 | */ |
||
693 | protected function _gd_getThumbnail($path) |
||
709 | |||
710 | /** |
||
711 | * Publish permissions specified path item. |
||
712 | * |
||
713 | * @param string $path |
||
714 | * |
||
715 | * @return bool |
||
716 | */ |
||
717 | protected function _gd_publish($path) |
||
734 | |||
735 | /** |
||
736 | * unPublish permissions specified path. |
||
737 | * |
||
738 | * @param string $path |
||
739 | * |
||
740 | * @return bool |
||
741 | */ |
||
742 | protected function _gd_unPublish($path) |
||
767 | |||
768 | /** |
||
769 | * Read file chunk. |
||
770 | * |
||
771 | * @param resource $handle |
||
772 | * @param int $chunkSize |
||
773 | * |
||
774 | * @return string |
||
775 | */ |
||
776 | protected function _gd_readFileChunk($handle, $chunkSize) |
||
792 | |||
793 | /** |
||
794 | * Return fileinfo based on filename |
||
795 | * For item ID based path file system |
||
796 | * Please override if needed on each drivers. |
||
797 | * |
||
798 | * @param string $path file cache |
||
799 | * |
||
800 | * @return array |
||
801 | */ |
||
802 | protected function isNameExists($path) |
||
813 | |||
814 | /*********************************************************************/ |
||
815 | /* INIT AND CONFIGURE */ |
||
816 | /*********************************************************************/ |
||
817 | |||
818 | /** |
||
819 | * Prepare FTP connection |
||
820 | * Connect to remote server and check if credentials are correct, if so, store the connection id in $ftp_conn. |
||
821 | * |
||
822 | * @return bool |
||
823 | * |
||
824 | * @author Dmitry (dio) Levashov |
||
825 | * @author Cem (DiscoFever) |
||
826 | **/ |
||
827 | protected function init() |
||
977 | |||
978 | /** |
||
979 | * Configure after successfull mount. |
||
980 | * |
||
981 | * @author Dmitry (dio) Levashov |
||
982 | **/ |
||
983 | View Code Duplication | protected function configure() |
|
999 | |||
1000 | /** |
||
1001 | * Cache dir contents. |
||
1002 | * |
||
1003 | * @param string $path dir path |
||
1004 | * |
||
1005 | * @author Dmitry Levashov |
||
1006 | **/ |
||
1007 | protected function cacheDir($path) |
||
1043 | |||
1044 | /** |
||
1045 | * Recursive files search. |
||
1046 | * |
||
1047 | * @param string $path dir path |
||
1048 | * @param string $q search string |
||
1049 | * @param array $mimes |
||
1050 | * |
||
1051 | * @return array |
||
1052 | * |
||
1053 | * @author Naoki Sawada |
||
1054 | **/ |
||
1055 | protected function doSearch($path, $q, $mimes) |
||
1116 | |||
1117 | /** |
||
1118 | * Copy file/recursive copy dir only in current volume. |
||
1119 | * Return new file path or false. |
||
1120 | * |
||
1121 | * @param string $src source path |
||
1122 | * @param string $dst destination dir path |
||
1123 | * @param string $name new file name (optionaly) |
||
1124 | * |
||
1125 | * @return string|false |
||
1126 | * |
||
1127 | * @author Dmitry (dio) Levashov |
||
1128 | * @author Naoki Sawada |
||
1129 | **/ |
||
1130 | protected function copy($src, $dst, $name) |
||
1161 | |||
1162 | /** |
||
1163 | * Remove file/ recursive remove dir. |
||
1164 | * |
||
1165 | * @param string $path file path |
||
1166 | * @param bool $force try to remove even if file locked |
||
1167 | * |
||
1168 | * @return bool |
||
1169 | * |
||
1170 | * @author Dmitry (dio) Levashov |
||
1171 | * @author Naoki Sawada |
||
1172 | **/ |
||
1173 | View Code Duplication | protected function remove($path, $force = false, $recursive = false) |
|
1202 | |||
1203 | /** |
||
1204 | * Create thumnbnail and return it's URL on success. |
||
1205 | * |
||
1206 | * @param string $path file path |
||
1207 | * @param string $mime file mime type |
||
1208 | * |
||
1209 | * @return string|false |
||
1210 | * |
||
1211 | * @author Dmitry (dio) Levashov |
||
1212 | * @author Naoki Sawada |
||
1213 | **/ |
||
1214 | View Code Duplication | protected function createTmb($path, $stat) |
|
1270 | |||
1271 | /** |
||
1272 | * Return thumbnail file name for required file. |
||
1273 | * |
||
1274 | * @param array $stat file stat |
||
1275 | * |
||
1276 | * @return string |
||
1277 | * |
||
1278 | * @author Dmitry (dio) Levashov |
||
1279 | **/ |
||
1280 | protected function tmbname($stat) |
||
1284 | |||
1285 | /*********************** paths/urls *************************/ |
||
1286 | |||
1287 | /** |
||
1288 | * Return parent directory path. |
||
1289 | * |
||
1290 | * @param string $path file path |
||
1291 | * |
||
1292 | * @return string |
||
1293 | * |
||
1294 | * @author Dmitry (dio) Levashov |
||
1295 | **/ |
||
1296 | protected function _dirname($path) |
||
1302 | |||
1303 | /** |
||
1304 | * Return file name. |
||
1305 | * |
||
1306 | * @param string $path file path |
||
1307 | * |
||
1308 | * @return string |
||
1309 | * |
||
1310 | * @author Dmitry (dio) Levashov |
||
1311 | **/ |
||
1312 | protected function _basename($path) |
||
1318 | |||
1319 | /** |
||
1320 | * Join dir name and file name and retur full path. |
||
1321 | * |
||
1322 | * @param string $dir |
||
1323 | * @param string $name |
||
1324 | * |
||
1325 | * @return string |
||
1326 | * |
||
1327 | * @author Dmitry (dio) Levashov |
||
1328 | **/ |
||
1329 | protected function _joinPath($dir, $name) |
||
1333 | |||
1334 | /** |
||
1335 | * Return normalized path, this works the same as os.path.normpath() in Python. |
||
1336 | * |
||
1337 | * @param string $path path |
||
1338 | * |
||
1339 | * @return string |
||
1340 | * |
||
1341 | * @author Troex Nevelin |
||
1342 | **/ |
||
1343 | View Code Duplication | protected function _normpath($path) |
|
1352 | |||
1353 | /** |
||
1354 | * Return file path related to root dir. |
||
1355 | * |
||
1356 | * @param string $path file path |
||
1357 | * |
||
1358 | * @return string |
||
1359 | * |
||
1360 | * @author Dmitry (dio) Levashov |
||
1361 | **/ |
||
1362 | protected function _relpath($path) |
||
1366 | |||
1367 | /** |
||
1368 | * Convert path related to root dir into real path. |
||
1369 | * |
||
1370 | * @param string $path file path |
||
1371 | * |
||
1372 | * @return string |
||
1373 | * |
||
1374 | * @author Dmitry (dio) Levashov |
||
1375 | **/ |
||
1376 | protected function _abspath($path) |
||
1380 | |||
1381 | /** |
||
1382 | * Return fake path started from root dir. |
||
1383 | * |
||
1384 | * @param string $path file path |
||
1385 | * |
||
1386 | * @return string |
||
1387 | * |
||
1388 | * @author Dmitry (dio) Levashov |
||
1389 | **/ |
||
1390 | protected function _path($path) |
||
1404 | |||
1405 | /** |
||
1406 | * Return true if $path is children of $parent. |
||
1407 | * |
||
1408 | * @param string $path path to check |
||
1409 | * @param string $parent parent path |
||
1410 | * |
||
1411 | * @return bool |
||
1412 | * |
||
1413 | * @author Dmitry (dio) Levashov |
||
1414 | **/ |
||
1415 | protected function _inpath($path, $parent) |
||
1419 | |||
1420 | /***************** file stat ********************/ |
||
1421 | |||
1422 | /** |
||
1423 | * Return stat for given path. |
||
1424 | * Stat contains following fields: |
||
1425 | * - (int) size file size in b. required |
||
1426 | * - (int) ts file modification time in unix time. required |
||
1427 | * - (string) mime mimetype. required for folders, others - optionally |
||
1428 | * - (bool) read read permissions. required |
||
1429 | * - (bool) write write permissions. required |
||
1430 | * - (bool) locked is object locked. optionally |
||
1431 | * - (bool) hidden is object hidden. optionally |
||
1432 | * - (string) alias for symlinks - link target path relative to root path. optionally |
||
1433 | * - (string) target for symlinks - link target path. optionally. |
||
1434 | * |
||
1435 | * If file does not exists - returns empty array or false. |
||
1436 | * |
||
1437 | * @param string $path file path |
||
1438 | * |
||
1439 | * @return array|false |
||
1440 | * |
||
1441 | * @author Dmitry (dio) Levashov |
||
1442 | **/ |
||
1443 | protected function _stat($path) |
||
1451 | |||
1452 | /** |
||
1453 | * Return true if path is dir and has at least one childs directory. |
||
1454 | * |
||
1455 | * @param string $path dir path |
||
1456 | * |
||
1457 | * @return bool |
||
1458 | * |
||
1459 | * @author Dmitry (dio) Levashov |
||
1460 | **/ |
||
1461 | protected function _subdirs($path) |
||
1470 | |||
1471 | /** |
||
1472 | * Return object width and height |
||
1473 | * Ususaly used for images, but can be realize for video etc... |
||
1474 | * |
||
1475 | * @param string $path file path |
||
1476 | * @param string $mime file mime type |
||
1477 | * |
||
1478 | * @return string |
||
1479 | * |
||
1480 | * @author Dmitry (dio) Levashov |
||
1481 | **/ |
||
1482 | protected function _dimensions($path, $mime) |
||
1497 | |||
1498 | /******************** file/dir content *********************/ |
||
1499 | |||
1500 | /** |
||
1501 | * Return files list in directory. |
||
1502 | * |
||
1503 | * @param string $path dir path |
||
1504 | * |
||
1505 | * @return array |
||
1506 | * |
||
1507 | * @author Dmitry (dio) Levashov |
||
1508 | * @author Cem (DiscoFever) |
||
1509 | **/ |
||
1510 | protected function _scandir($path) |
||
1516 | |||
1517 | /** |
||
1518 | * Open file and return file pointer. |
||
1519 | * |
||
1520 | * @param string $path file path |
||
1521 | * @param bool $write open file for writing |
||
1522 | * |
||
1523 | * @return resource|false |
||
1524 | * |
||
1525 | * @author Dmitry (dio) Levashov |
||
1526 | **/ |
||
1527 | protected function _fopen($path, $mode = 'rb') |
||
1559 | |||
1560 | /** |
||
1561 | * Close opened file. |
||
1562 | * |
||
1563 | * @param resource $fp file pointer |
||
1564 | * |
||
1565 | * @return bool |
||
1566 | * |
||
1567 | * @author Dmitry (dio) Levashov |
||
1568 | **/ |
||
1569 | protected function _fclose($fp, $path = '') |
||
1576 | |||
1577 | /******************** file/dir manipulations *************************/ |
||
1578 | |||
1579 | /** |
||
1580 | * Create dir and return created dir path or false on failed. |
||
1581 | * |
||
1582 | * @param string $path parent dir path |
||
1583 | * @param string $name new directory name |
||
1584 | * |
||
1585 | * @return string|bool |
||
1586 | * |
||
1587 | * @author Dmitry (dio) Levashov |
||
1588 | **/ |
||
1589 | protected function _mkdir($path, $name) |
||
1616 | |||
1617 | /** |
||
1618 | * Create file and return it's path or false on failed. |
||
1619 | * |
||
1620 | * @param string $path parent dir path |
||
1621 | * @param string $name new file name |
||
1622 | * |
||
1623 | * @return string|bool |
||
1624 | * |
||
1625 | * @author Dmitry (dio) Levashov |
||
1626 | **/ |
||
1627 | protected function _mkfile($path, $name) |
||
1631 | |||
1632 | /** |
||
1633 | * Create symlink. FTP driver does not support symlinks. |
||
1634 | * |
||
1635 | * @param string $target link target |
||
1636 | * @param string $path symlink path |
||
1637 | * |
||
1638 | * @return bool |
||
1639 | * |
||
1640 | * @author Dmitry (dio) Levashov |
||
1641 | **/ |
||
1642 | protected function _symlink($target, $path, $name) |
||
1646 | |||
1647 | /** |
||
1648 | * Copy file into another file. |
||
1649 | * |
||
1650 | * @param string $source source file path |
||
1651 | * @param string $targetDir target directory path |
||
1652 | * @param string $name new file name |
||
1653 | * |
||
1654 | * @return bool |
||
1655 | * |
||
1656 | * @author Dmitry (dio) Levashov |
||
1657 | **/ |
||
1658 | protected function _copy($source, $targetDir, $name) |
||
1682 | |||
1683 | /** |
||
1684 | * Move file into another parent dir. |
||
1685 | * Return new file path or false. |
||
1686 | * |
||
1687 | * @param string $source source file path |
||
1688 | * @param string $target target dir path |
||
1689 | * @param string $name file name |
||
1690 | * |
||
1691 | * @return string|bool |
||
1692 | * |
||
1693 | * @author Dmitry (dio) Levashov |
||
1694 | **/ |
||
1695 | protected function _move($source, $targetDir, $name) |
||
1719 | |||
1720 | /** |
||
1721 | * Remove file. |
||
1722 | * |
||
1723 | * @param string $path file path |
||
1724 | * |
||
1725 | * @return bool |
||
1726 | * |
||
1727 | * @author Dmitry (dio) Levashov |
||
1728 | **/ |
||
1729 | protected function _unlink($path) |
||
1744 | |||
1745 | /** |
||
1746 | * Remove dir. |
||
1747 | * |
||
1748 | * @param string $path dir path |
||
1749 | * |
||
1750 | * @return bool |
||
1751 | * |
||
1752 | * @author Dmitry (dio) Levashov |
||
1753 | **/ |
||
1754 | protected function _rmdir($path) |
||
1761 | |||
1762 | /** |
||
1763 | * Create new file and write into it from file pointer. |
||
1764 | * Return new file path or false on error. |
||
1765 | * |
||
1766 | * @param resource $fp file pointer |
||
1767 | * @param string $dir target dir path |
||
1768 | * @param string $name file name |
||
1769 | * @param array $stat file stat (required by some virtual fs) |
||
1770 | * |
||
1771 | * @return bool|string |
||
1772 | * |
||
1773 | * @author Dmitry (dio) Levashov |
||
1774 | **/ |
||
1775 | protected function _save($fp, $path, $name, $stat) |
||
1894 | |||
1895 | /** |
||
1896 | * Get file contents. |
||
1897 | * |
||
1898 | * @param string $path file path |
||
1899 | * |
||
1900 | * @return string|false |
||
1901 | * |
||
1902 | * @author Dmitry (dio) Levashov |
||
1903 | **/ |
||
1904 | protected function _getContents($path) |
||
1921 | |||
1922 | /** |
||
1923 | * Write a string to a file. |
||
1924 | * |
||
1925 | * @param string $path file path |
||
1926 | * @param string $content new file content |
||
1927 | * |
||
1928 | * @return bool |
||
1929 | * |
||
1930 | * @author Dmitry (dio) Levashov |
||
1931 | **/ |
||
1932 | View Code Duplication | protected function _filePutContents($path, $content) |
|
1948 | |||
1949 | /** |
||
1950 | * Detect available archivers. |
||
1951 | **/ |
||
1952 | protected function _checkArchivers() |
||
1957 | |||
1958 | /** |
||
1959 | * chmod implementation. |
||
1960 | * |
||
1961 | * @return bool |
||
1962 | **/ |
||
1963 | protected function _chmod($path, $mode) |
||
1967 | |||
1968 | /** |
||
1969 | * Unpack archive. |
||
1970 | * |
||
1971 | * @param string $path archive path |
||
1972 | * @param array $arc archiver command and arguments (same as in $this->archivers) |
||
1973 | * |
||
1974 | * @return true |
||
1975 | * |
||
1976 | * @author Dmitry (dio) Levashov |
||
1977 | * @author Alexey Sukhotin |
||
1978 | **/ |
||
1979 | protected function _unpack($path, $arc) |
||
1984 | |||
1985 | /** |
||
1986 | * Recursive symlinks search. |
||
1987 | * |
||
1988 | * @param string $path file/dir path |
||
1989 | * |
||
1990 | * @return bool |
||
1991 | * |
||
1992 | * @author Dmitry (dio) Levashov |
||
1993 | **/ |
||
1994 | protected function _findSymlinks($path) |
||
1998 | |||
1999 | /** |
||
2000 | * Extract files from archive. |
||
2001 | * |
||
2002 | * @param string $path archive path |
||
2003 | * @param array $arc archiver command and arguments (same as in $this->archivers) |
||
2004 | * |
||
2005 | * @return true |
||
2006 | * |
||
2007 | * @author Dmitry (dio) Levashov, |
||
2008 | * @author Alexey Sukhotin |
||
2009 | **/ |
||
2010 | protected function _extract($path, $arc) |
||
2014 | |||
2015 | /** |
||
2016 | * Create archive and return its path. |
||
2017 | * |
||
2018 | * @param string $dir target dir |
||
2019 | * @param array $files files names list |
||
2020 | * @param string $name archive name |
||
2021 | * @param array $arc archiver options |
||
2022 | * |
||
2023 | * @return string|bool |
||
2024 | * |
||
2025 | * @author Dmitry (dio) Levashov, |
||
2026 | * @author Alexey Sukhotin |
||
2027 | **/ |
||
2028 | protected function _archive($dir, $files, $name, $arc) |
||
2032 | |||
2033 | /** |
||
2034 | * Drive query and fetchAll. |
||
2035 | * |
||
2036 | * @param string $sql |
||
2037 | * |
||
2038 | * @return bool|array |
||
2039 | */ |
||
2040 | private function _gd_query($opts) |
||
2069 | |||
2070 | /** |
||
2071 | * Get dat(googledrive metadata) from GoogleDrive. |
||
2072 | * |
||
2073 | * @param string $path |
||
2074 | * |
||
2075 | * @return array googledrive metadata |
||
2076 | */ |
||
2077 | private function _gd_getFile($path, $fields = '') |
||
2094 | |||
2095 | /** |
||
2096 | * Get dat(googledrive metadata) from GoogleDrive. |
||
2097 | * |
||
2098 | * @param string $path |
||
2099 | * |
||
2100 | * @return array googledrive metadata |
||
2101 | */ |
||
2102 | private function _gd_getNameByPath($path) |
||
2111 | } // END class |
||
2112 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.