StatusService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

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
    public function __construct(IConfig $settings, Config $config, $AppName) {
28
        $this->settings = $settings;
29
        $this->config = $config;
30
        $this->appName = $AppName;
31
    }
32
33
    public function isProperlyConfigured() {
34
        $cronMode = $this->settings->getAppValue(
35
            'core', 'backgroundjobs_mode'
36
        );
37
        $cronOff = !$this->config->getUseCronUpdates();
38
39
        // check for cron modes which may lead to problems
40
        return $cronMode === 'cron' || $cronOff;
41
    }
42
43
44
    public function getStatus() {
45
        $version = $this->settings->getAppValue(
46
            $this->appName, 'installed_version'
47
        );
48
49
        return [
50
            'version' => $version,
51
            'warnings' => [
52
                'improperlyConfiguredCron' => !$this->isProperlyConfigured()
53
            ]
54
        ];
55
    }
56
57
}