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 elFinderVolumeBox 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 elFinderVolumeBox, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
12 | class elFinderVolumeBox extends elFinderVolumeDriver |
||
13 | { |
||
14 | /** |
||
15 | * @var string The base URL for API requests |
||
16 | */ |
||
17 | const API_URL = 'https://api.box.com/2.0'; |
||
18 | |||
19 | /** |
||
20 | * @var string The base URL for authorization requests |
||
21 | */ |
||
22 | const AUTH_URL = 'https://www.box.com/api/oauth2/authorize'; |
||
23 | |||
24 | /** |
||
25 | * @var string The base URL for token requests |
||
26 | */ |
||
27 | const TOKEN_URL = 'https://www.box.com/api/oauth2/token'; |
||
28 | |||
29 | /** |
||
30 | * @var string The base URL for upload requests |
||
31 | */ |
||
32 | const UPLOAD_URL = 'https://upload.box.com/api/2.0'; |
||
33 | |||
34 | /** |
||
35 | * Fetch fields list. |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | const FETCHFIELDS = 'type,id,name,created_at,modified_at,description,size,parent,permissions,file_version,shared_link'; |
||
40 | |||
41 | /** |
||
42 | * Net mount key. |
||
43 | * |
||
44 | * @var string |
||
45 | **/ |
||
46 | public $netMountKey = ''; |
||
47 | /** |
||
48 | * Driver id |
||
49 | * Must be started from letter and contains [a-z0-9] |
||
50 | * Used as part of volume id. |
||
51 | * |
||
52 | * @var string |
||
53 | **/ |
||
54 | protected $driverId = 'bd'; |
||
55 | |||
56 | /** |
||
57 | * Box.com token object. |
||
58 | * |
||
59 | * @var object |
||
60 | **/ |
||
61 | protected $token = null; |
||
62 | |||
63 | /** |
||
64 | * Directory for tmp files |
||
65 | * If not set driver will try to use tmbDir as tmpDir. |
||
66 | * |
||
67 | * @var string |
||
68 | **/ |
||
69 | protected $tmp = ''; |
||
70 | |||
71 | /** |
||
72 | * hasCache by folders. |
||
73 | * |
||
74 | * @var array |
||
75 | **/ |
||
76 | protected $HasdirsCache = []; |
||
77 | |||
78 | /** |
||
79 | * Thumbnail prefix. |
||
80 | * |
||
81 | * @var string |
||
82 | **/ |
||
83 | private $tmbPrefix = ''; |
||
84 | |||
85 | /** |
||
86 | * Constructor |
||
87 | * Extend options with required fields. |
||
88 | * |
||
89 | * @author Dmitry (dio) Levashov |
||
90 | * @author Cem (DiscoFever) |
||
91 | **/ |
||
92 | View Code Duplication | public function __construct() |
|
110 | |||
111 | /*********************************************************************/ |
||
112 | /* OVERRIDE FUNCTIONS */ |
||
113 | /*********************************************************************/ |
||
114 | |||
115 | /** |
||
116 | * Prepare |
||
117 | * Call from elFinder::netmout() before volume->mount(). |
||
118 | * |
||
119 | * @return array |
||
120 | * |
||
121 | * @author Naoki Sawada |
||
122 | * @author Raja Sharma updating for Box |
||
123 | **/ |
||
124 | public function netmountPrepare($options) |
||
282 | |||
283 | /** |
||
284 | * process of on netunmount |
||
285 | * Drop `box` & rm thumbs. |
||
286 | * |
||
287 | * @param array $options |
||
288 | * |
||
289 | * @return bool |
||
290 | */ |
||
291 | View Code Duplication | public function netunmount($netVolumes, $key) |
|
301 | |||
302 | /*********************************************************************/ |
||
303 | /* FS API */ |
||
304 | /*********************************************************************/ |
||
305 | |||
306 | /** |
||
307 | * Close opened connection. |
||
308 | * |
||
309 | * @author Dmitry (dio) Levashov |
||
310 | **/ |
||
311 | public function umount() |
||
314 | |||
315 | /** |
||
316 | * Return content URL. |
||
317 | * |
||
318 | * @param string $hash file hash |
||
319 | * @param array $options options |
||
320 | * |
||
321 | * @return string |
||
322 | * |
||
323 | * @author Naoki Sawada |
||
324 | **/ |
||
325 | public function getContentUrl($hash, $options = []) |
||
359 | |||
360 | /*********************************************************************/ |
||
361 | /* ORIGINAL FUNCTIONS */ |
||
362 | /*********************************************************************/ |
||
363 | |||
364 | /** |
||
365 | * Get Parent ID, Item ID, Parent Path as an array from path. |
||
366 | * |
||
367 | * @param string $path |
||
368 | * |
||
369 | * @return array |
||
370 | */ |
||
371 | View Code Duplication | protected function _bd_splitPath($path) |
|
392 | |||
393 | /** |
||
394 | * Obtains a new access token from OAuth. This token is valid for one hour. |
||
395 | * |
||
396 | * @param string $clientSecret The Box client secret |
||
397 | * @param string $code The code returned by Box after |
||
398 | * successful log in |
||
399 | * @param string $redirectUri Must be the same as the redirect URI passed |
||
400 | * to LoginUrl |
||
401 | * |
||
402 | * @throws \Exception Thrown if this Client instance's clientId is not set |
||
403 | * @throws \Exception Thrown if the redirect URI of this Client instance's |
||
404 | * state is not set |
||
405 | */ |
||
406 | protected function _bd_obtainAccessToken($client_id, $client_secret, $code) |
||
448 | |||
449 | /** |
||
450 | * Get token and auto refresh. |
||
451 | * |
||
452 | * @return true|string error message |
||
453 | */ |
||
454 | protected function _bd_refreshToken() |
||
511 | |||
512 | /** |
||
513 | * Creates a base cURL object which is compatible with the Box.com API. |
||
514 | * |
||
515 | * @param array $options cURL options |
||
516 | * |
||
517 | * @return resource A compatible cURL object |
||
518 | */ |
||
519 | protected function _bd_prepareCurl($options = []) |
||
532 | |||
533 | /** |
||
534 | * Creates a base cURL object which is compatible with the Box.com API. |
||
535 | * |
||
536 | * @param string $path The path of the API call (eg. /folders/0) |
||
537 | * |
||
538 | * @return resource A compatible cURL object |
||
539 | */ |
||
540 | protected function _bd_fetch($url, $contents = false) |
||
579 | |||
580 | /** |
||
581 | * Call curl_exec(). |
||
582 | * |
||
583 | * @param resource $curl |
||
584 | * @param bool|string $decodeOrParent |
||
585 | * @param array $headers |
||
586 | * |
||
587 | * @throws \Exception |
||
588 | * |
||
589 | * @return mixed |
||
590 | */ |
||
591 | protected function _bd_curlExec($curl, $decodeOrParent = true, $headers = []) |
||
635 | |||
636 | /** |
||
637 | * Drive query and fetchAll. |
||
638 | * |
||
639 | * @param string $sql |
||
640 | * |
||
641 | * @return bool|array |
||
642 | */ |
||
643 | protected function _bd_query($itemId, $fetch_self = false, $recursive = false) |
||
679 | |||
680 | /** |
||
681 | * Get dat(box metadata) from Box.com. |
||
682 | * |
||
683 | * @param string $path |
||
684 | * |
||
685 | * @return array box metadata |
||
686 | */ |
||
687 | protected function _bd_getRawItem($path) |
||
701 | |||
702 | /** |
||
703 | * Parse line from box metadata output and return file stat (array). |
||
704 | * |
||
705 | * @param string $raw line from ftp_rawlist() output |
||
706 | * |
||
707 | * @return array |
||
708 | * |
||
709 | * @author Dmitry Levashov |
||
710 | **/ |
||
711 | protected function _bd_parseRaw($raw) |
||
738 | |||
739 | /** |
||
740 | * Get thumbnail from Box.com. |
||
741 | * |
||
742 | * @param string $path |
||
743 | * @param string $size |
||
744 | * |
||
745 | * @return string | boolean |
||
746 | */ |
||
747 | View Code Duplication | protected function _bd_getThumbnail($path) |
|
761 | |||
762 | /** |
||
763 | * Remove item. |
||
764 | * |
||
765 | * @param string $path file path |
||
766 | * |
||
767 | * @return bool |
||
768 | **/ |
||
769 | protected function _bd_unlink($path, $type = null) |
||
793 | |||
794 | /*********************************************************************/ |
||
795 | /* INIT AND CONFIGURE */ |
||
796 | /*********************************************************************/ |
||
797 | |||
798 | /** |
||
799 | * Prepare FTP connection |
||
800 | * Connect to remote server and check if credentials are correct, if so, store the connection id in $ftp_conn. |
||
801 | * |
||
802 | * @return bool |
||
803 | * |
||
804 | * @author Dmitry (dio) Levashov |
||
805 | * @author Cem (DiscoFever) |
||
806 | **/ |
||
807 | protected function init() |
||
868 | |||
869 | /** |
||
870 | * Configure after successfull mount. |
||
871 | * |
||
872 | * @author Dmitry (dio) Levashov |
||
873 | **/ |
||
874 | protected function configure() |
||
886 | |||
887 | /** |
||
888 | * Return fileinfo based on filename |
||
889 | * For item ID based path file system |
||
890 | * Please override if needed on each drivers. |
||
891 | * |
||
892 | * @param string $path file cache |
||
893 | * |
||
894 | * @return array |
||
895 | */ |
||
896 | protected function isNameExists($path) |
||
930 | |||
931 | /** |
||
932 | * Cache dir contents. |
||
933 | * |
||
934 | * @param string $path dir path |
||
935 | * |
||
936 | * @author Dmitry Levashov |
||
937 | **/ |
||
938 | protected function cacheDir($path) |
||
973 | |||
974 | /** |
||
975 | * Copy file/recursive copy dir only in current volume. |
||
976 | * Return new file path or false. |
||
977 | * |
||
978 | * @param string $src source path |
||
979 | * @param string $dst destination dir path |
||
980 | * @param string $name new file name (optionaly) |
||
981 | * |
||
982 | * @return string|false |
||
983 | * |
||
984 | * @author Dmitry (dio) Levashov |
||
985 | * @author Naoki Sawada |
||
986 | **/ |
||
987 | protected function copy($src, $dst, $name) |
||
995 | |||
996 | /** |
||
997 | * Remove file/ recursive remove dir. |
||
998 | * |
||
999 | * @param string $path file path |
||
1000 | * @param bool $force try to remove even if file locked |
||
1001 | * |
||
1002 | * @return bool |
||
1003 | * |
||
1004 | * @author Dmitry (dio) Levashov |
||
1005 | * @author Naoki Sawada |
||
1006 | **/ |
||
1007 | View Code Duplication | protected function remove($path, $force = false) |
|
1036 | |||
1037 | /** |
||
1038 | * Create thumnbnail and return it's URL on success. |
||
1039 | * |
||
1040 | * @param string $path file path |
||
1041 | * @param string $mime file mime type |
||
1042 | * |
||
1043 | * @return string|false |
||
1044 | * |
||
1045 | * @author Dmitry (dio) Levashov |
||
1046 | * @author Naoki Sawada |
||
1047 | **/ |
||
1048 | View Code Duplication | protected function createTmb($path, $stat) |
|
1104 | |||
1105 | /** |
||
1106 | * Return thumbnail file name for required file. |
||
1107 | * |
||
1108 | * @param array $stat file stat |
||
1109 | * |
||
1110 | * @return string |
||
1111 | * |
||
1112 | * @author Dmitry (dio) Levashov |
||
1113 | **/ |
||
1114 | protected function tmbname($stat) |
||
1118 | |||
1119 | /** |
||
1120 | * Return content URL. |
||
1121 | * |
||
1122 | * @param array $raw data |
||
1123 | * |
||
1124 | * @return array |
||
1125 | * |
||
1126 | * @author Naoki Sawada |
||
1127 | **/ |
||
1128 | protected function getSharedWebContentLink($raw) |
||
1157 | |||
1158 | /*********************** paths/urls *************************/ |
||
1159 | |||
1160 | /** |
||
1161 | * Return parent directory path. |
||
1162 | * |
||
1163 | * @param string $path file path |
||
1164 | * |
||
1165 | * @return string |
||
1166 | * |
||
1167 | * @author Dmitry (dio) Levashov |
||
1168 | **/ |
||
1169 | protected function _dirname($path) |
||
1175 | |||
1176 | /** |
||
1177 | * Return file name. |
||
1178 | * |
||
1179 | * @param string $path file path |
||
1180 | * |
||
1181 | * @return string |
||
1182 | * |
||
1183 | * @author Dmitry (dio) Levashov |
||
1184 | **/ |
||
1185 | protected function _basename($path) |
||
1191 | |||
1192 | /** |
||
1193 | * Join dir name and file name and retur full path. |
||
1194 | * |
||
1195 | * @param string $dir |
||
1196 | * @param string $name |
||
1197 | * |
||
1198 | * @return string |
||
1199 | * |
||
1200 | * @author Dmitry (dio) Levashov |
||
1201 | **/ |
||
1202 | protected function _joinPath($dir, $name) |
||
1210 | |||
1211 | /** |
||
1212 | * Return normalized path, this works the same as os.path.normpath() in Python. |
||
1213 | * |
||
1214 | * @param string $path path |
||
1215 | * |
||
1216 | * @return string |
||
1217 | * |
||
1218 | * @author Troex Nevelin |
||
1219 | **/ |
||
1220 | View Code Duplication | protected function _normpath($path) |
|
1229 | |||
1230 | /** |
||
1231 | * Return file path related to root dir. |
||
1232 | * |
||
1233 | * @param string $path file path |
||
1234 | * |
||
1235 | * @return string |
||
1236 | * |
||
1237 | * @author Dmitry (dio) Levashov |
||
1238 | **/ |
||
1239 | protected function _relpath($path) |
||
1243 | |||
1244 | /** |
||
1245 | * Convert path related to root dir into real path. |
||
1246 | * |
||
1247 | * @param string $path file path |
||
1248 | * |
||
1249 | * @return string |
||
1250 | * |
||
1251 | * @author Dmitry (dio) Levashov |
||
1252 | **/ |
||
1253 | protected function _abspath($path) |
||
1257 | |||
1258 | /** |
||
1259 | * Return fake path started from root dir. |
||
1260 | * |
||
1261 | * @param string $path file path |
||
1262 | * |
||
1263 | * @return string |
||
1264 | * |
||
1265 | * @author Dmitry (dio) Levashov |
||
1266 | **/ |
||
1267 | protected function _path($path) |
||
1271 | |||
1272 | /** |
||
1273 | * Return true if $path is children of $parent. |
||
1274 | * |
||
1275 | * @param string $path path to check |
||
1276 | * @param string $parent parent path |
||
1277 | * |
||
1278 | * @return bool |
||
1279 | * |
||
1280 | * @author Dmitry (dio) Levashov |
||
1281 | **/ |
||
1282 | protected function _inpath($path, $parent) |
||
1286 | |||
1287 | /***************** file stat ********************/ |
||
1288 | |||
1289 | /** |
||
1290 | * Return stat for given path. |
||
1291 | * Stat contains following fields: |
||
1292 | * - (int) size file size in b. required |
||
1293 | * - (int) ts file modification time in unix time. required |
||
1294 | * - (string) mime mimetype. required for folders, others - optionally |
||
1295 | * - (bool) read read permissions. required |
||
1296 | * - (bool) write write permissions. required |
||
1297 | * - (bool) locked is object locked. optionally |
||
1298 | * - (bool) hidden is object hidden. optionally |
||
1299 | * - (string) alias for symlinks - link target path relative to root path. optionally |
||
1300 | * - (string) target for symlinks - link target path. optionally. |
||
1301 | * |
||
1302 | * If file does not exists - returns empty array or false. |
||
1303 | * |
||
1304 | * @param string $path file path |
||
1305 | * |
||
1306 | * @return array|false |
||
1307 | * |
||
1308 | * @author Dmitry (dio) Levashov |
||
1309 | **/ |
||
1310 | protected function _stat($path) |
||
1318 | |||
1319 | /** |
||
1320 | * Return true if path is dir and has at least one childs directory. |
||
1321 | * |
||
1322 | * @param string $path dir path |
||
1323 | * |
||
1324 | * @return bool |
||
1325 | * |
||
1326 | * @author Dmitry (dio) Levashov |
||
1327 | **/ |
||
1328 | protected function _subdirs($path) |
||
1344 | |||
1345 | /** |
||
1346 | * Return object width and height |
||
1347 | * Ususaly used for images, but can be realize for video etc... |
||
1348 | * |
||
1349 | * @param string $path file path |
||
1350 | * @param string $mime file mime type |
||
1351 | * |
||
1352 | * @return string |
||
1353 | * |
||
1354 | * @author Dmitry (dio) Levashov |
||
1355 | **/ |
||
1356 | protected function _dimensions($path, $mime) |
||
1374 | |||
1375 | /******************** file/dir content *********************/ |
||
1376 | |||
1377 | /** |
||
1378 | * Return files list in directory. |
||
1379 | * |
||
1380 | * @param string $path dir path |
||
1381 | * |
||
1382 | * @return array |
||
1383 | * |
||
1384 | * @author Dmitry (dio) Levashov |
||
1385 | * @author Cem (DiscoFever) |
||
1386 | **/ |
||
1387 | protected function _scandir($path) |
||
1393 | |||
1394 | /** |
||
1395 | * Open file and return file pointer. |
||
1396 | * |
||
1397 | * @param string $path file path |
||
1398 | * @param bool $write open file for writing |
||
1399 | * |
||
1400 | * @return resource|false |
||
1401 | * |
||
1402 | * @author Dmitry (dio) Levashov |
||
1403 | **/ |
||
1404 | View Code Duplication | protected function _fopen($path, $mode = 'rb') |
|
1418 | |||
1419 | /** |
||
1420 | * Close opened file. |
||
1421 | * |
||
1422 | * @param resource $fp file pointer |
||
1423 | * |
||
1424 | * @return bool |
||
1425 | * |
||
1426 | * @author Dmitry (dio) Levashov |
||
1427 | **/ |
||
1428 | protected function _fclose($fp, $path = '') |
||
1435 | |||
1436 | /******************** file/dir manipulations *************************/ |
||
1437 | |||
1438 | /** |
||
1439 | * Create dir and return created dir path or false on failed. |
||
1440 | * |
||
1441 | * @param string $path parent dir path |
||
1442 | * @param string $name new directory name |
||
1443 | * |
||
1444 | * @return string|bool |
||
1445 | * |
||
1446 | * @author Dmitry (dio) Levashov |
||
1447 | **/ |
||
1448 | protected function _mkdir($path, $name) |
||
1470 | |||
1471 | /** |
||
1472 | * Create file and return it's path or false on failed. |
||
1473 | * |
||
1474 | * @param string $path parent dir path |
||
1475 | * @param string $name new file name |
||
1476 | * |
||
1477 | * @return string|bool |
||
1478 | * |
||
1479 | * @author Dmitry (dio) Levashov |
||
1480 | **/ |
||
1481 | protected function _mkfile($path, $name) |
||
1485 | |||
1486 | /** |
||
1487 | * Create symlink. FTP driver does not support symlinks. |
||
1488 | * |
||
1489 | * @param string $target link target |
||
1490 | * @param string $path symlink path |
||
1491 | * |
||
1492 | * @return bool |
||
1493 | * |
||
1494 | * @author Dmitry (dio) Levashov |
||
1495 | **/ |
||
1496 | protected function _symlink($target, $path, $name) |
||
1500 | |||
1501 | /** |
||
1502 | * Copy file into another file. |
||
1503 | * |
||
1504 | * @param string $source source file path |
||
1505 | * @param string $targetDir target directory path |
||
1506 | * @param string $name new file name |
||
1507 | * |
||
1508 | * @return string|false |
||
1509 | * |
||
1510 | * @author Dmitry (dio) Levashov |
||
1511 | **/ |
||
1512 | protected function _copy($source, $targetDir, $name) |
||
1549 | |||
1550 | /** |
||
1551 | * Move file into another parent dir. |
||
1552 | * Return new file path or false. |
||
1553 | * |
||
1554 | * @param string $source source file path |
||
1555 | * @param string $target target dir path |
||
1556 | * @param string $name file name |
||
1557 | * |
||
1558 | * @return string|bool |
||
1559 | * |
||
1560 | * @author Dmitry (dio) Levashov |
||
1561 | **/ |
||
1562 | protected function _move($source, $targetDir, $name) |
||
1599 | |||
1600 | /** |
||
1601 | * Remove file. |
||
1602 | * |
||
1603 | * @param string $path file path |
||
1604 | * |
||
1605 | * @return bool |
||
1606 | * |
||
1607 | * @author Dmitry (dio) Levashov |
||
1608 | **/ |
||
1609 | protected function _unlink($path) |
||
1613 | |||
1614 | /** |
||
1615 | * Remove dir. |
||
1616 | * |
||
1617 | * @param string $path dir path |
||
1618 | * |
||
1619 | * @return bool |
||
1620 | * |
||
1621 | * @author Dmitry (dio) Levashov |
||
1622 | **/ |
||
1623 | protected function _rmdir($path) |
||
1627 | |||
1628 | /** |
||
1629 | * Create new file and write into it from file pointer. |
||
1630 | * Return new file path or false on error. |
||
1631 | * |
||
1632 | * @param resource $fp file pointer |
||
1633 | * @param string $dir target dir path |
||
1634 | * @param string $name file name |
||
1635 | * @param array $stat file stat (required by some virtual fs) |
||
1636 | * |
||
1637 | * @return bool|string |
||
1638 | * |
||
1639 | * @author Dmitry (dio) Levashov |
||
1640 | **/ |
||
1641 | protected function _save($fp, $path, $name, $stat) |
||
1700 | |||
1701 | /** |
||
1702 | * Get file contents. |
||
1703 | * |
||
1704 | * @param string $path file path |
||
1705 | * |
||
1706 | * @return string|false |
||
1707 | * |
||
1708 | * @author Dmitry (dio) Levashov |
||
1709 | **/ |
||
1710 | View Code Duplication | protected function _getContents($path) |
|
1725 | |||
1726 | /** |
||
1727 | * Write a string to a file. |
||
1728 | * |
||
1729 | * @param string $path file path |
||
1730 | * @param string $content new file content |
||
1731 | * |
||
1732 | * @return bool |
||
1733 | * |
||
1734 | * @author Dmitry (dio) Levashov |
||
1735 | **/ |
||
1736 | View Code Duplication | protected function _filePutContents($path, $content) |
|
1752 | |||
1753 | /** |
||
1754 | * Detect available archivers. |
||
1755 | **/ |
||
1756 | protected function _checkArchivers() |
||
1761 | |||
1762 | /** |
||
1763 | * chmod implementation. |
||
1764 | * |
||
1765 | * @return bool |
||
1766 | **/ |
||
1767 | protected function _chmod($path, $mode) |
||
1771 | |||
1772 | /** |
||
1773 | * Unpack archive. |
||
1774 | * |
||
1775 | * @param string $path archive path |
||
1776 | * @param array $arc archiver command and arguments (same as in $this->archivers) |
||
1777 | * |
||
1778 | * @return true |
||
1779 | * |
||
1780 | * @author Dmitry (dio) Levashov |
||
1781 | * @author Alexey Sukhotin |
||
1782 | **/ |
||
1783 | protected function _unpack($path, $arc) |
||
1788 | |||
1789 | /** |
||
1790 | * Recursive symlinks search. |
||
1791 | * |
||
1792 | * @param string $path file/dir path |
||
1793 | * |
||
1794 | * @return bool |
||
1795 | * |
||
1796 | * @author Dmitry (dio) Levashov |
||
1797 | **/ |
||
1798 | protected function _findSymlinks($path) |
||
1802 | |||
1803 | /** |
||
1804 | * Extract files from archive. |
||
1805 | * |
||
1806 | * @param string $path archive path |
||
1807 | * @param array $arc archiver command and arguments (same as in $this->archivers) |
||
1808 | * |
||
1809 | * @return true |
||
1810 | * |
||
1811 | * @author Dmitry (dio) Levashov, |
||
1812 | * @author Alexey Sukhotin |
||
1813 | **/ |
||
1814 | protected function _extract($path, $arc) |
||
1818 | |||
1819 | /** |
||
1820 | * Create archive and return its path. |
||
1821 | * |
||
1822 | * @param string $dir target dir |
||
1823 | * @param array $files files names list |
||
1824 | * @param string $name archive name |
||
1825 | * @param array $arc archiver options |
||
1826 | * |
||
1827 | * @return string|bool |
||
1828 | * |
||
1829 | * @author Dmitry (dio) Levashov, |
||
1830 | * @author Alexey Sukhotin |
||
1831 | **/ |
||
1832 | protected function _archive($dir, $files, $name, $arc) |
||
1836 | } // END class |
||
1837 |
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.