Passed
Push — master ( da3e39...86ff87 )
by Alec
03:15
created

EventIndicator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * User: alec
4
 * Date: 16.11.18
5
 * Time: 13:41
6
 */
7
8
namespace AlecRabbit\Event;
9
10
class EventIndicator
11
{
12
    public const THRESHOLD = 60;
13
14
    /** @var int */
15
    private $lastEventTimestamp;
16
17
    /**
18
     * EventIndicator constructor.
19
     */
20
    public function __construct()
21
    {
22
        $this->event();
23
    }
24
25
    public function event(): void
26
    {
27
        $this->lastEventTimestamp = $this->current();
28
    }
29
30
    /**
31
     * @return int
32
     */
33
    private function current(): int
34
    {
35
        return time();
36
    }
37
38
    /**
39
     * @return bool
40
     */
41
    public function isOk(): bool
42
    {
43
        return
44
            $this->current() - $this->lastEventTimestamp >= 60;
45
    }
46
}