ExpireActivities::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, ownCloud, Inc.
4
 *
5
 * @author Joas Schilling <[email protected]>
6
 *
7
 * @license AGPL-3.0
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
23
namespace OCA\Activity\BackgroundJob;
24
25
use OC\BackgroundJob\TimedJob;
26
use OCA\Activity\Data;
27
use OCP\IConfig;
28
29
/**
30
 * Class ExpireActivities
31
 *
32
 * @package OCA\Activity\BackgroundJob
33
 */
34
class ExpireActivities extends TimedJob {
35
	/** @var Data */
36
	protected $data;
37
	/** @var IConfig */
38
	protected $config;
39
40
	/**
41
	 * @param Data $data
42
	 * @param IConfig $config
43
	 */
44 4
	public function __construct(Data $data, IConfig $config) {
45
		// Run once per day
46 4
		$this->setInterval(60 * 60 * 24);
47
48 4
		$this->data = $data;
49 4
		$this->config = $config;
50 4
	}
51
52 2
	protected function run($argument) {
53
		// Remove activities that are older then one year
54 2
		$expireDays = $this->config->getSystemValue('activity_expire_days', 365);
55 2
		$this->data->expire($expireDays);
56 2
	}
57
}
58