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

Upgrade::upgrade()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
ccs 8
cts 8
cp 1
rs 9.6667
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 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