CollectionsController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 29
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getCollections() 5 5 1
A setVisibility() 5 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * ownCloud - Tasks
4
 *
5
 * @author Raimund Schlüßler
6
 * @copyright 2017 Raimund Schlüßler [email protected]
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
 * License as published by the Free Software Foundation; either
11
 * version 3 of the License, or any later version.
12
 *
13
 * This library 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
19
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
23
namespace OCA\Tasks\Controller;
24
25
use \OCA\Tasks\Service\CollectionsService;
26
use \OCP\IRequest;
27
use \OCP\AppFramework\Controller;
28
29 View Code Duplication
class CollectionsController extends Controller {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
31
	private $collectionsService;
32
33
	use Response;
34
35
	public function __construct($appName, IRequest $request, CollectionsService $collectionsService){
36
		parent::__construct($appName, $request);
37
		$this->collectionsService = $collectionsService;
38
	}
39
40
	/**
41
	 * @NoAdminRequired
42
	 */
43
	public function getCollections(){
44
		return $this->generateResponse(function () {
45
			return ['collections' => $this->collectionsService->getAll()];
46
		});
47
	}
48
49
	/**
50
	 * @NoAdminRequired
51
	 */
52
	public function setVisibility($collectionID, $visibility){
53
		return $this->generateResponse(function () use ($collectionID, $visibility) {
54
			return $this->collectionsService->setVisibility($collectionID, $visibility);
55
		});
56
	}
57
}
58