Completed
Push — master ( 050ca4...6f48a7 )
by
unknown
05:54
created

Upgrade   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 33
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A upgrade() 0 9 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 Bernhard Posselt <[email protected]>
9
 * @copyright Bernhard Posselt 2015
10
 */
11
12
namespace OCA\News\Upgrade;
13
14
use OCP\IConfig;
15
use OCA\News\Service\ItemService;
16
17
class Upgrade {
18
19
    /** @var IConfig */
20
    private $config;
21
22
    /** @var ItemService */
23
    private $itemService;
24
25
    private $appName;
26
27
    /**
28
     * Upgrade constructor.
29
     * @param IConfig $config
30
     * @param $appName
31
     */
32 2
    public function __construct(IConfig $config, ItemService $itemService,
33
                                $appName) {
34 2
        $this->config = $config;
35 2
        $this->appName = $appName;
36 2
        $this->itemService = $itemService;
37 2
    }
38
39 2
    public function upgrade() {
40 2
        $previousVersion = $this->config->getAppValue(
41 2
            $this->appName, 'installed_version'
42 2
        );
43
44 2
        if (version_compare($previousVersion, '7', '<')) {
45 1
            $this->itemService->generateSearchIndices();
46 1
        }
47 2
    }
48
49
}
50