Completed
Pull Request — master (#93)
by Janis
12:34
created

AppConfig::setAppValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
/**
4
 * Nextcloud - OCR
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the COPYING file.
8
 *
9
 * @author Janis Koehr <[email protected]>
10
 * @copyright Janis Koehr 2017
11
 */
12
namespace OCA\Ocr\Config;
13
14
use \OCP\IConfig;
15
16
class AppConfig{
17
	
18
	private $appName = 'ocr';
19
	private $defaults = [
20
			'languages' => 'eng;fra;spa;deu'
21
	];
22
	private $config;
23
	public function __construct(IConfig $config) {
24
		$this->config = $config;
25
	}
26
	/**
27
	 * Get a value by key
28
	 * @param string $key
29
	 * @return string
30
	 */
31
	public function getAppValue($key) {
32
		$defaultValue = null;
33
		if (array_key_exists($key, $this->defaults)){
34
			$defaultValue = $this->defaults[$key];
35
		}
36
		return $this->config->getAppValue($this->appName, $key, $defaultValue);
37
	}
38
	/**
39
	 * Set a value by key
40
	 * @param string $key
41
	 * @param string $value
42
	 * @return string
43
	 */
44
	public function setAppValue($key, $value) {
45
		return $this->config->setAppValue($this->appName, $key, $value);
46
	}
47
}