ProcessCallbackTask   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 75
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1
rs 10

5 Methods

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