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

StatusService::isProperlyConfigured()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
ccs 7
cts 7
cp 1
cc 2
eloc 5
nc 2
nop 0
crap 2
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
}