| Conditions | 5 |
| Paths | 6 |
| Total Lines | 61 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 48 | public function getCapabilities() { |
||
| 49 | $res = []; |
||
| 50 | |||
| 51 | if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { |
||
| 52 | $res['api_enabled'] = false; |
||
| 53 | $res['public'] = ['enabled' => false]; |
||
| 54 | $res['user'] = ['send_mail' => false]; |
||
| 55 | $res['resharing'] = false; |
||
| 56 | } else { |
||
| 57 | $res['api_enabled'] = true; |
||
| 58 | |||
| 59 | $public = []; |
||
| 60 | $public['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes'; |
||
| 61 | if ($public['enabled']) { |
||
| 62 | $public['password'] = []; |
||
| 63 | $public['password']['enforced'] = ($this->config->getAppValue('core', 'shareapi_enforce_links_password', 'no') === 'yes'); |
||
| 64 | |||
| 65 | if ($public['password']['enforced']) { |
||
| 66 | $public['password']['askForOptionalPassword'] = false; |
||
| 67 | } else { |
||
| 68 | $public['password']['askForOptionalPassword'] = ($this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no') === 'yes'); |
||
| 69 | } |
||
| 70 | |||
| 71 | $public['expire_date'] = []; |
||
| 72 | $public['multiple_links'] = true; |
||
| 73 | $public['expire_date']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; |
||
| 74 | if ($public['expire_date']['enabled']) { |
||
| 75 | $public['expire_date']['days'] = $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
||
| 76 | $public['expire_date']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; |
||
| 77 | } |
||
| 78 | |||
| 79 | $public['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no') === 'yes'; |
||
| 80 | $public['upload'] = $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === 'yes'; |
||
| 81 | $public['upload_files_drop'] = $public['upload']; |
||
| 82 | } |
||
| 83 | $res['public'] = $public; |
||
| 84 | |||
| 85 | $res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes'; |
||
| 86 | |||
| 87 | $res['user']['send_mail'] = false; |
||
| 88 | $res['user']['expire_date']['enabled'] = true; |
||
| 89 | |||
| 90 | // deprecated in favour of 'group', but we need to keep it for now |
||
| 91 | // in order to stay compatible with older clients |
||
| 92 | $res['group_sharing'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes'; |
||
| 93 | |||
| 94 | $res['group'] = []; |
||
| 95 | $res['group']['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes'; |
||
| 96 | $res['group']['expire_date']['enabled'] = true; |
||
| 97 | $res['default_permissions'] = (int)$this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL); |
||
| 98 | } |
||
| 99 | |||
| 100 | //Federated sharing |
||
| 101 | $res['federation'] = [ |
||
| 102 | 'outgoing' => $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes', |
||
| 103 | 'incoming' => $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes', |
||
| 104 | 'expire_date' => ['enabled' => true] |
||
| 105 | ]; |
||
| 106 | |||
| 107 | return [ |
||
| 108 | 'files_sharing' => $res, |
||
| 109 | ]; |
||
| 112 |