Completed
Push — master ( e4992c...6d0a35 )
by
unknown
10:42
created

Provider::buildProviderList()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 53

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 8
nop 0
dl 0
loc 53
rs 9.0254
c 0
b 0
f 0

How to fix   Long Method   

Long Method

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:

1
<?php
2
/**
3
 * @author Joas Schilling <[email protected]>
4
 * @author Lukas Reschke <[email protected]>
5
 *
6
 * @copyright Copyright (c) 2018, ownCloud GmbH
7
 * @license AGPL-3.0
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
23
namespace OC\OCS;
24
25
class Provider extends \OCP\AppFramework\Controller {
26
	/** @var \OCP\App\IAppManager */
27
	private $appManager;
28
29
	/**
30
	 * @param string $appName
31
	 * @param \OCP\IRequest $request
32
	 * @param \OCP\App\IAppManager $appManager
33
	 */
34
	public function __construct($appName,
35
								\OCP\IRequest $request,
36
								\OCP\App\IAppManager $appManager) {
37
		parent::__construct($appName, $request);
38
		$this->appManager = $appManager;
39
	}
40
41
	/**
42
	 * @return \OCP\AppFramework\Http\JSONResponse
43
	 */
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