| Conditions | 4 |
| Paths | 8 |
| Total Lines | 53 |
| 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 |
||
| 44 | public function buildProviderList() { |
||
| 45 | $services = [ |
||
| 46 | 'PRIVATE_DATA' => [ |
||
| 47 | 'version' => 1, |
||
| 48 | 'endpoints' => [ |
||
| 49 | 'store' => '/ocs/v2.php/privatedata/setattribute', |
||
| 50 | 'read' => '/ocs/v2.php/privatedata/getattribute', |
||
| 51 | 'delete' => '/ocs/v2.php/privatedata/deleteattribute', |
||
| 52 | ], |
||
| 53 | ], |
||
| 54 | ]; |
||
| 55 | |||
| 56 | if ($this->appManager->isEnabledForUser('files_sharing')) { |
||
| 57 | $services['SHARING'] = [ |
||
| 58 | 'version' => 1, |
||
| 59 | 'endpoints' => [ |
||
| 60 | 'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares', |
||
| 61 | ], |
||
| 62 | ]; |
||
| 63 | $services['FEDERATED_SHARING'] = [ |
||
| 64 | 'version' => 1, |
||
| 65 | 'endpoints' => [ |
||
| 66 | 'share' => '/ocs/v2.php/cloud/shares', |
||
| 67 | 'webdav' => '/public.php/webdav/', |
||
| 68 | ], |
||
| 69 | ]; |
||
| 70 | } |
||
| 71 | |||
| 72 | if ($this->appManager->isEnabledForUser('activity')) { |
||
| 73 | $services['ACTIVITY'] = [ |
||
| 74 | 'version' => 1, |
||
| 75 | 'endpoints' => [ |
||
| 76 | 'list' => '/ocs/v2.php/cloud/activity', |
||
| 77 | ], |
||
| 78 | ]; |
||
| 79 | } |
||
| 80 | |||
| 81 | if ($this->appManager->isEnabledForUser('provisioning_api')) { |
||
| 82 | $services['PROVISIONING'] = [ |
||
| 83 | 'version' => 1, |
||
| 84 | 'endpoints' => [ |
||
| 85 | 'user' => '/ocs/v2.php/cloud/users', |
||
| 86 | 'groups' => '/ocs/v2.php/cloud/groups', |
||
| 87 | 'apps' => '/ocs/v2.php/cloud/apps', |
||
| 88 | ], |
||
| 89 | ]; |
||
| 90 | } |
||
| 91 | |||
| 92 | return new \OCP\AppFramework\Http\JSONResponse([ |
||
| 93 | 'version' => 2, |
||
| 94 | 'services' => $services, |
||
| 95 | ]); |
||
| 96 | } |
||
| 97 | } |
||
| 98 |