Conditions | 4 |
Paths | 4 |
Total Lines | 75 |
Code Lines | 58 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
36 | public function getConfiguration() |
||
37 | { |
||
38 | if ($this->allow()) { |
||
39 | $userId = api_get_user_id(); |
||
40 | |||
41 | if (!empty($userId)) { |
||
42 | // Adding user personal files |
||
43 | $dir = \UserManager::getUserPathById($userId, 'system'); |
||
44 | $dirWeb = \UserManager::getUserPathById($userId, 'web'); |
||
45 | $mimeType = [ |
||
46 | 'application', |
||
47 | 'text/html', |
||
48 | 'text/javascript', |
||
49 | 'text/ecmascript', |
||
50 | 'image/svg+xml', |
||
51 | 'image/svg', |
||
52 | ]; |
||
53 | |||
54 | $driver = [ |
||
55 | 'driver' => 'PersonalDriver', |
||
56 | 'alias' => get_lang('MyFiles'), |
||
57 | 'path' => $dir.'my_files', |
||
58 | 'URL' => $dirWeb.'my_files', |
||
59 | 'accessControl' => [$this, 'access'], |
||
60 | 'uploadDeny' => $mimeType, |
||
61 | 'disabled' => [ |
||
62 | 'duplicate', |
||
63 | //'rename', |
||
64 | //'mkdir', |
||
65 | 'mkfile', |
||
66 | 'copy', |
||
67 | 'cut', |
||
68 | 'paste', |
||
69 | 'edit', |
||
70 | 'extract', |
||
71 | 'archive', |
||
72 | 'help', |
||
73 | 'resize', |
||
74 | ], |
||
75 | ]; |
||
76 | if (api_get_configuration_value('social_myfiles_office_files_upload_allowed')) { |
||
77 | //Allow all office suite documents to be uploaded in the "My files" section of the social network |
||
78 | $driver['uploadOrder'] = ['deny', 'allow']; |
||
79 | $driver['uploadAllow'] = [ |
||
80 | 'application/pdf', |
||
81 | 'application/msword', |
||
82 | 'application/vnd.ms-excel', |
||
83 | 'application/vnd.ms-excel.addin.macroEnabled.12', |
||
84 | 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', |
||
85 | 'application/vnd.ms-excel.sheet.macroEnabled.12', |
||
86 | 'application/vnd.ms-excel.template.macroEnabled.12', |
||
87 | 'application/vnd.ms-powerpoint', |
||
88 | 'application/vnd.ms-powerpoint.addin.macroEnabled.12', |
||
89 | 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', |
||
90 | 'application/vnd.ms-powerpoint.slide.macroenabled.12', |
||
91 | 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', |
||
92 | 'application/vnd.ms-powerpoint.template.macroEnabled.12', |
||
93 | 'application/vnd.ms-word.document.macroEnabled.12', |
||
94 | 'application/vnd.ms-word.template.macroEnabled.12', |
||
95 | 'application/vnd.openxmlformats-officedocument.presentationml.presentation', |
||
96 | 'application/vnd.openxmlformats-officedocument.presentationml.slide', |
||
97 | 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', |
||
98 | 'application/vnd.openxmlformats-officedocument.presentationml.template', |
||
99 | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
||
100 | 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', |
||
101 | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
||
102 | 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', |
||
103 | ]; |
||
104 | } |
||
105 | |||
106 | return $driver; |
||
107 | } |
||
108 | } |
||
109 | |||
110 | return []; |
||
111 | } |
||
145 |