Test Failed
Push — trunk ( e02d87...314b8c )
by SuperNova.WS
07:20
created

TaskPeriodic::condition()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 3
nc 4
nop 0
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * Created by Gorlum 08.02.2020 15:44
4
 */
5
6
namespace Core\Scheduler;
7
8
use classConfig;
9
10
/**
11
 * Periodic task - task which runs in time intervals, i.e. each 10 minutes
12
 *
13
 * @package Core
14
 */
15
class TaskPeriodic extends TaskConditional {
16
  /**
17
   * Interval to run task
18
   *
19
   * @var int $interval
20
   */
21
  protected $interval = 0;
22
23
  /**
24
   * @return bool
25
   */
26
  protected function isTaskAllowed() {
27
    return $this->interval > 0 && parent::isTaskAllowed();
28
  }
29
30
  /**
31
   * @return bool
32
   */
33
  public function condition() {
34
    $this->forceConfigLoad ? $this->config->pass() : false;
35
    $configValue = $this->config->dateRead($this->configName, classConfig::DATE_TYPE_UNIX);
36
37
    return ($this->interval > 0) && (SN_TIME_NOW - $configValue > $this->interval);
38
  }
39
40
}
41