Completed
Pull Request — master (#93)
by Janis
04:19
created

Admin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 50
ccs 18
cts 18
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getForm() 0 13 1
A getSection() 0 3 1
A getPriority() 0 3 1
1
<?php
2
3
/**
4
 * Nextcloud - OCR
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 * 
8
 * @author Janis Koehr <[email protected]>
9
 * @copyright Janis Koehr 2017
10
 */
11
namespace OCA\Ocr\Settings;
12
13
use OCP\Settings\ISettings;
14
use OCP\IConfig;
15
use OCP\AppFramework\Http\TemplateResponse;
16
use OCA\Ocr\Constants\OcrConstants;
17
18
19
class Admin implements ISettings {
20
21
    /** @var IConfig */
22
    private $config;
23
24
    /**
25
     *
26
     * @param IConfig $config            
27
     */
28 4
    public function __construct(IConfig $config) {
29 4
        $this->config = $config;
30 4
    }
31
32
    /**
33
     *
34
     * @return TemplateResponse
35
     */
36 2
    public function getForm() {
37 2
        return new TemplateResponse('ocr', 'settings-admin', 
38
                [
39 2
                        OcrConstants::LANGUAGES_CONFIG_KEY => $this->config->getAppValue('ocr', 
40 2
                                OcrConstants::LANGUAGES_CONFIG_KEY),
41 2
                        OcrConstants::REDIS_CONFIG_KEY_HOST => $this->config->getAppValue('ocr', 
42 2
                                OcrConstants::REDIS_CONFIG_KEY_HOST),
43 2
                        OcrConstants::REDIS_CONFIG_KEY_PORT => $this->config->getAppValue('ocr', 
44 2
                                OcrConstants::REDIS_CONFIG_KEY_PORT),
45 2
                        OcrConstants::REDIS_CONFIG_KEY_DB => $this->config->getAppValue('ocr', 
46 2
                                OcrConstants::REDIS_CONFIG_KEY_DB)
47 2
                ], 'blank');
48
    }
49
50
    /**
51
     *
52
     * @return string the section ID, e.g. 'sharing'
53
     */
54 1
    public function getSection() {
55 1
        return 'ocr';
56
    }
57
58
    /**
59
     *
60
     * @return int whether the form should be rather on the top or bottom of
61
     *         the admin section. The forms are arranged in ascending order of the
62
     *         priority values. It is required to return a value between 0 and 100.
63
     *         keep the server setting at the top, right after "server settings"
64
     */
65 1
    public function getPriority() {
66 1
        return 0;
67
    }
68
}