Completed
Pull Request — master (#207)
by korelstar
41:14
created

SettingsController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 4 1
A get() 0 3 1
A __construct() 0 8 1
1
<?php
2
namespace OCA\Notes\Controller;
3
use OCP\AppFramework\Controller;
4
5
use OCP\IConfig;
6
use OCP\IRequest;
7
use OCP\IUserManager;
8
use OCP\IUserSession;
9
use OCP\Files\IRootFolder;
10
use OCP\AppFramework\Http\JSONResponse;
11
use OCA\Notes\Service\SettingsService;
12
13
class SettingsController extends Controller
14
{
15
	private $service;
16
17
	public function __construct(
18
		$appName,
19
		IRequest $request,
20
		SettingsService $service
21
	) {
22
		parent::__construct($appName, $request);
23
		$this->service = $service;
24
	}
25
26
	/**
27
	 * @NoAdminRequired
28
	 * @throws \OCP\PreConditionNotMetException
29
	 */
30
	public function set() {
31
		$this->service->set($this->request->getParams());
32
		return $this->get();
33
	}
34
35
	/**
36
	 * @NoAdminRequired
37
	 */
38
	public function get() {
39
		return new JSONResponse($this->service->get());
40
	}
41
}
42