Code Duplication    Length = 24-27 lines in 2 locations

lib/private/BackgroundJob/TimedJob.php 1 location

@@ 35-58 (lines=24) @@
32
 *
33
 * @package OC\BackgroundJob
34
 */
35
abstract class TimedJob extends Job {
36
	protected $interval = 0;
37
38
	/**
39
	 * set the interval for the job
40
	 *
41
	 * @param int $interval
42
	 */
43
	public function setInterval($interval) {
44
		$this->interval = $interval;
45
	}
46
47
	/**
48
	 * run the job if
49
	 *
50
	 * @param JobList $jobList
51
	 * @param ILogger|null $logger
52
	 */
53
	public function execute($jobList, ILogger $logger = null) {
54
		if ((time() - $this->lastRun) > $this->interval) {
55
			parent::execute($jobList, $logger);
56
		}
57
	}
58
}
59

lib/public/BackgroundJob/TimedJob.php 1 location

@@ 36-62 (lines=27) @@
33
 *
34
 * @since 15.0.0
35
 */
36
abstract class TimedJob extends Job {
37
	/** @var int */
38
	protected $interval = 0;
39
40
	/**
41
	 * set the interval for the job
42
	 *
43
	 * @since 15.0.0
44
	 */
45
	public function setInterval(int $interval) {
46
		$this->interval = $interval;
47
	}
48
49
	/**
50
	 * run the job if the last run is is more than the interval ago
51
	 *
52
	 * @param JobList $jobList
53
	 * @param ILogger|null $logger
54
	 *
55
	 * @since 15.0.0
56
	 */
57
	final public function execute($jobList, ILogger $logger = null) {
58
		if (($this->time->getTime() - $this->lastRun) > $this->interval) {
59
			parent::execute($jobList, $logger);
60
		}
61
	}
62
}
63