CardController   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 1
dl 0
loc 113
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A rename() 0 3 1
A archive() 0 3 1
A unarchive() 0 3 1
A assignLabel() 0 3 1
A removeLabel() 0 3 1
A __construct() 0 5 1
A read() 0 3 1
A reorder() 0 3 1
A create() 0 3 1
A update() 0 3 1
A delete() 0 3 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Julius Härtl <[email protected]>
4
 *
5
 * @author Julius Härtl <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *  
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *  
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *  
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *  
22
 */
23
24
namespace OCA\Deck\Controller;
25
26
use OCA\Deck\Service\CardService;
27
use OCP\IRequest;
28
use OCP\AppFramework\Controller;
29
30
class CardController extends Controller {
31
32
	private $userId;
33
	private $cardService;
34
35
	public function __construct($appName, IRequest $request, CardService $cardService, $userId) {
36
		parent::__construct($appName, $request);
37
		$this->userId = $userId;
38
		$this->cardService = $cardService;
39
	}
40
41
	/**
42
	 * @NoAdminRequired
43
	 * @param $cardId
44
	 * @return \OCP\AppFramework\Db\Entity
45
	 */
46
	public function read($cardId) {
47
		return $this->cardService->find($cardId);
48
	}
49
50
	/**
51
	 * @NoAdminRequired
52
	 * @param $cardId
53
	 * @param $stackId
54
	 * @param $order
55
	 * @return array
56
	 */
57
	public function reorder($cardId, $stackId, $order) {
58
		return $this->cardService->reorder($cardId, $stackId, $order);
59
	}
60
61
	/**
62
	 * @NoAdminRequired
63
	 * @param $cardId
64
	 * @param $title
65
	 * @return \OCP\AppFramework\Db\Entity
66
	 */
67
	public function rename($cardId, $title) {
68
		return $this->cardService->rename($cardId, $title);
69
	}
70
71
	/**
72
	 * @NoAdminRequired
73
	 * @param $title
74
	 * @param $stackId
75
	 * @param $type
76
	 * @param int $order
77
	 * @return \OCP\AppFramework\Db\Entity
78
	 */
79
	public function create($title, $stackId, $type, $order = 999) {
80
		return $this->cardService->create($title, $stackId, $type, $order, $this->userId);
81
	}
82
83
	/**
84
	 * @NoAdminRequired
85
	 * @param $id
86
	 * @param $title
87
	 * @param $stackId
88
	 * @param $type
89
	 * @param $order
90
	 * @param $description
91
	 * @return \OCP\AppFramework\Db\Entity
92
	 */
93
	public function update($id, $title, $stackId, $type, $order, $description) {
94
			return $this->cardService->update($id, $title, $stackId, $type, $order, $description, $this->userId);
95
	}
96
97
	/**
98
	 * @NoAdminRequired
99
	 * @param $cardId
100
	 * @return \OCP\AppFramework\Db\Entity
101
	 */
102
	public function delete($cardId) {
103
		return $this->cardService->delete($cardId);
104
	}
105
106
	/**
107
	 * @NoAdminRequired
108
	 * @param $cardId
109
	 * @return \OCP\AppFramework\Db\Entity
110
	 */
111
	public function archive($cardId) {
112
		return $this->cardService->archive($cardId);
113
	}
114
115
	/**
116
	 * @NoAdminRequired
117
	 * @param $cardId
118
	 * @return \OCP\AppFramework\Db\Entity
119
	 */
120
	public function unarchive($cardId) {
121
		return $this->cardService->unarchive($cardId);
122
	}
123
124
	/**
125
	 * @NoAdminRequired
126
	 * @param $cardId
127
	 * @param $labelId
128
	 */
129
	public function assignLabel($cardId, $labelId) {
130
		$this->cardService->assignLabel($cardId, $labelId);
131
	}
132
133
	/**
134
	 * @NoAdminRequired
135
	 * @param $cardId
136
	 * @param $labelId
137
	 */
138
	public function removeLabel($cardId, $labelId) {
139
		$this->cardService->removeLabel($cardId, $labelId);
140
	}
141
142
}
143