ProcessCallbackTask::getExpiresIn()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace AsyncPHP\Doorman\Task;
4
5
use AsyncPHP\Doorman\Expires;
6
use AsyncPHP\Doorman\Process;
7
8
final class ProcessCallbackTask extends CallbackTask implements Expires, Process
9
{
10
    /**
11
     * @var null|int
12
     */
13
    private $id;
14
15
    /**
16
     * @var null|int
17
     */
18
    private $expiredAt;
19
20
    /**
21
     * @inheritdoc
22
     *
23
     * @return null|int
24
     */
25 1
    public function getId()
26
    {
27 1
        return $this->id;
28
    }
29
30
    /**
31
     * @inheritdoc
32
     *
33
     * @param int $id
34
     *
35
     * @return $this
36
     */
37 1
    public function setId($id)
38
    {
39 1
        $this->id = $id;
40
41 1
        return $this;
42
    }
43
44
    /**
45
     * @inheritdoc
46
     *
47
     * @return int
48
     */
49 1
    public function getExpiresIn()
50
    {
51 1
        return -1;
52
    }
53
54
    /**
55
     * @inheritdoc
56
     *
57
     * @param int $startedAt
58
     *
59
     * @return bool
60
     */
61 1
    public function shouldExpire($startedAt)
62
    {
63 1
        $this->expiredAt = time();
64
65 1
        return true;
66
    }
67
68
    /**
69
     * Checks whether this task has expired.
70
     *
71
     * @return bool
72
     */
73 1
    public function hasExpired()
74
    {
75 1
        return is_int($this->expiredAt);
76
    }
77
}
78