Passed
Push — master ( fce6df...8e01ff )
by Georg
14:04 queued 11s
created

ClearOldStatusesBackgroundJob::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @copyright Copyright (c) 2020, Georg Ehrke
7
 *
8
 * @author Georg Ehrke <[email protected]>
9
 *
10
 * @license AGPL-3.0
11
 *
12
 * This code is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License, version 3,
14
 * as published by the Free Software Foundation.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License, version 3,
22
 * along with this program. If not, see <http://www.gnu.org/licenses/>
23
 *
24
 */
25
26
namespace OCA\UserStatus\BackgroundJob;
27
28
use OCA\UserStatus\Db\UserStatusMapper;
29
use OCP\AppFramework\Utility\ITimeFactory;
30
use OCP\BackgroundJob\TimedJob;
31
32
/**
33
 * Class ClearOldStatusesBackgroundJob
34
 *
35
 * @package OCA\UserStatus\BackgroundJob
36
 */
37
class ClearOldStatusesBackgroundJob extends TimedJob {
38
39
	/** @var UserStatusMapper */
40
	private $mapper;
41
42
	/**
43
	 * ClearOldStatusesBackgroundJob constructor.
44
	 *
45
	 * @param ITimeFactory $time
46
	 * @param UserStatusMapper $mapper
47
	 */
48
	public function __construct(ITimeFactory $time,
49
								UserStatusMapper $mapper) {
50
		parent::__construct($time);
51
		$this->mapper = $mapper;
52
53
		// Run every time the cron is run
54
		$this->setInterval(60);
55
	}
56
57
	/**
58
	 * @inheritDoc
59
	 */
60
	protected function run($argument) {
61
		$this->mapper->clearOlderThan($this->time->getTime());
62
	}
63
}
64