Completed
Push — master ( 87cd4f...db10a3 )
by
unknown
04:19
created

StatusService   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isProperlyConfigured() 0 9 2
A getStatus() 0 12 1
1
<?php
2
/**
3
 * ownCloud - News
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Alessandro Cosentino <[email protected]>
9
 * @author Bernhard Posselt <[email protected]>
10
 * @copyright Alessandro Cosentino 2012
11
 * @copyright Bernhard Posselt 2012, 2014
12
 */
13
14
namespace OCA\News\Service;
15
16
use OCP\IConfig;
17
18
use OCA\News\Config\Config;
19
20
21
class StatusService {
22
23
    private $settings;
24
    private $config;
25
    private $appName;
26
27 3
    public function __construct(IConfig $settings, Config $config, $AppName) {
28 3
        $this->settings = $settings;
29 3
        $this->config = $config;
30 3
        $this->appName = $AppName;
31 3
    }
32
33
    public function isProperlyConfigured() {
34 3
        $cronMode = $this->settings->getAppValue(
35 3
            'core', 'backgroundjobs_mode'
36
        );
37 3
        $cronOff = !$this->config->getUseCronUpdates();
38 3
39 3
        // check for cron modes which may lead to problems
40 3
        return $cronMode === 'cron' || $cronOff;
41 3
    }
42 3
43 3
44
    public function getStatus() {
45
        $version = $this->settings->getAppValue(
46 3
            $this->appName, 'installed_version'
47 1
        );
48 1
49
        return [
50
            'version' => $version,
51
            'warnings' => [
52 3
                'improperlyConfiguredCron' => !$this->isProperlyConfigured()
53
            ]
54
        ];
55 3
    }
56
57
}