Completed
Push — master ( 95d6ab...2eb143 )
by Maxence
02:46
created

ConfigService::getCloudVersion()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
/**
3
 * Mood
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Maxence Lange <[email protected]>
9
 * @copyright 2017
10
 * @license GNU AGPL version 3 or any later version
11
 *
12
 * This program is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License as
14
 * published by the Free Software Foundation, either version 3 of the
15
 * License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU Affero General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License
23
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 *
25
 *
26
 */
27
28
namespace OCA\Mood\Service;
29
30
use OCP\IConfig;
31
32
class ConfigService {
33
34
35
	private $defaults = [];
0 ignored issues
show
Unused Code introduced by
The property $defaults is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
36
37
	private $appName;
38
39
	private $config;
40
41
	private $miscService;
42
43
	public function __construct($appName, IConfig $config, $userId, MiscService $miscService) {
44
		$this->appName = $appName;
45
		$this->config = $config;
46
		$this->userId = $userId;
0 ignored issues
show
Bug introduced by
The property userId does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
47
		$this->miscService = $miscService;
48
	}
49
50
	/**
51
	 * Get a user value by key
52
	 *
53
	 * @param string $key
54
	 *
55
	 * @return string
56
	 */
57
	public function getUserValue($key) {
58
		return $this->config->getUserValue($this->userId, $this->appName, $key);
59
	}
60
61
	/**
62
	 * Set a user value by key
63
	 *
64
	 * @param string $key
65
	 * @param string $value
66
	 *
67
	 * @return string
68
	 */
69
	public function setUserValue($key, $value) {
70
		return $this->config->setUserValue($this->userId, $this->appName, $key, $value);
71
	}
72
73
}
74