Conditions | 7 |
Paths | 15 |
Total Lines | 70 |
Code Lines | 49 |
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 |
||
58 | public function getCapabilities() { |
||
59 | $res = []; |
||
60 | |||
61 | if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { |
||
62 | $res['api_enabled'] = false; |
||
63 | $res['public'] = ['enabled' => false]; |
||
64 | $res['user'] = ['send_mail' => false]; |
||
65 | $res['resharing'] = false; |
||
66 | } else { |
||
67 | $res['api_enabled'] = true; |
||
68 | |||
69 | $public = []; |
||
70 | $public['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes'; |
||
71 | if ($public['enabled']) { |
||
72 | $public['password'] = []; |
||
73 | $public['password']['enforced_for'] = []; |
||
74 | $roPasswordEnforced = $this->config->getAppValue('core', 'shareapi_enforce_links_password_read_only', 'no') === 'yes'; |
||
75 | $rwPasswordEnforced = $this->config->getAppValue('core', 'shareapi_enforce_links_password_read_write', 'no') === 'yes'; |
||
76 | $woPasswordEnforced = $this->config->getAppValue('core', 'shareapi_enforce_links_password_write_only', 'no') === 'yes'; |
||
77 | $public['password']['enforced_for']['read_only'] = $roPasswordEnforced; |
||
78 | $public['password']['enforced_for']['read_write'] = $rwPasswordEnforced; |
||
79 | $public['password']['enforced_for']['upload_only'] = $woPasswordEnforced; |
||
80 | $public['password']['enforced'] = $roPasswordEnforced || $rwPasswordEnforced || $woPasswordEnforced; |
||
81 | |||
82 | $public['expire_date'] = []; |
||
83 | $public['expire_date']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; |
||
84 | if ($public['expire_date']['enabled']) { |
||
85 | $public['expire_date']['days'] = $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
||
86 | $public['expire_date']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; |
||
87 | } |
||
88 | |||
89 | $public['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no') === 'yes'; |
||
90 | $public['social_share'] = $this->config->getAppValue('core', 'shareapi_allow_social_share', 'yes') === 'yes'; |
||
91 | $public['upload'] = $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === 'yes'; |
||
92 | $public['multiple'] = true; |
||
93 | $public['supports_upload_only'] = true; |
||
94 | } |
||
95 | $res["public"] = $public; |
||
96 | |||
97 | $res['user']['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'no') === 'yes'; |
||
98 | |||
99 | $res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes'; |
||
100 | |||
101 | $res['group_sharing'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes'; |
||
102 | |||
103 | $res['share_with_group_members_only'] = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'yes') === 'yes'; |
||
104 | $res['share_with_membership_groups_only'] = $this->config->getAppValue('core', 'shareapi_only_share_with_membership_groups', 'yes') === 'yes'; |
||
105 | |||
106 | $user_enumeration = []; |
||
107 | $user_enumeration['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes'; |
||
108 | if ($user_enumeration['enabled']) { |
||
109 | $user_enumeration['group_members_only'] = $this->config->getAppValue('core', 'shareapi_share_dialog_user_enumeration_group_members', 'no') === 'yes'; |
||
110 | } |
||
111 | $res["user_enumeration"] = $user_enumeration; |
||
112 | |||
113 | $res['default_permissions'] = (int)$this->config->getAppValue('core', 'shareapi_default_permissions', \OCP\Constants::PERMISSION_ALL); |
||
114 | } |
||
115 | |||
116 | //Federated sharing |
||
117 | $res['federation'] = [ |
||
118 | 'outgoing' => $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes', |
||
119 | 'incoming' => $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes' |
||
120 | ]; |
||
121 | |||
122 | $res['search_min_length'] = $this->userSearch->getSearchMinLength(); |
||
123 | |||
124 | return [ |
||
125 | 'files_sharing' => $res, |
||
126 | ]; |
||
127 | } |
||
128 | } |
||
129 |