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

AppConfig   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getAppValue() 0 7 2
A setAppValue() 0 3 1
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
}