Passed
Pull Request — master (#57)
by Matthew
07:36
created

Job::getCrcHash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Dtc\QueueBundle\Model;
4
5
class Job extends BaseJob
6
{
7
    const STATUS_EXPIRED = 'expired';
8
9
    protected $id;
10
    protected $message;
11
    protected $crcHash;
12
    protected $expiresAt;
13
    protected $delay;
14
    protected $startedAt;
15
    protected $maxDuration;
16
    protected $runId;
17
    protected $finishedAt;
18
    protected $elapsed;
19
20 100
    public function __call($method, $args)
21
    {
22 100
        $this->method = $method;
23 100
        $this->setArgs($args);
24
25
        // Make sure the method exists - job should not be created
26 100
        if (!method_exists($this->worker, $method)) {
27 1
            throw new \BadMethodCallException("{$this->className}->{$method}() does not exist");
28
        }
29
30 100
        $job = $this->jobManager->save($this);
31
32 100
        return $job;
33
    }
34
35
    /**
36
     * @return string|null
37
     */
38 41
    public function getMessage()
39
    {
40 41
        return $this->message;
41
    }
42
43
    /**
44
     * @param string $message
45
     */
46 33
    public function setMessage($message)
47
    {
48 33
        $this->message = $message;
49
50 33
        return $this;
51
    }
52
53
    /**
54
     * @return \DateTime|null
55
     */
56 79
    public function getExpiresAt()
57
    {
58 79
        return $this->expiresAt;
59
    }
60
61
    /**
62
     * @param \DateTime $expiresAt
63
     */
64 9
    public function setExpiresAt(\DateTime $expiresAt)
65
    {
66 9
        $this->expiresAt = $expiresAt;
67
68 9
        return $this;
69
    }
70
71
    /**
72
     * @return int
73
     */
74 108
    public function getId()
75
    {
76 108
        return $this->id;
77
    }
78
79
    /**
80
     * @return string
81
     */
82 94
    public function getCrcHash()
83
    {
84 94
        return $this->crcHash;
85
    }
86
87
    /**
88
     * @param mixed $id
89
     */
90 98
    public function setId($id)
91
    {
92 98
        $this->id = $id;
93
94 98
        return $this;
95
    }
96
97
    /**
98
     * @return \DateTime|null
99
     */
100 33
    public function getStartedAt()
101
    {
102 33
        return $this->startedAt;
103
    }
104
105
    /**
106
     * @param \DateTime|null $startedAt
107
     */
108 32
    public function setStartedAt(\DateTime $startedAt = null)
109
    {
110 32
        $this->startedAt = $startedAt;
111
112 32
        return $this;
113
    }
114
115
    /**
116
     * @return int|null
117
     */
118 40
    public function getMaxDuration()
119
    {
120 40
        return $this->maxDuration;
121
    }
122
123
    /**
124
     * @param int|null $maxDuration
125
     */
126 7
    public function setMaxDuration($maxDuration)
127
    {
128 7
        $this->maxDuration = $maxDuration;
129
130 7
        return $this;
131
    }
132
133
    /**
134
     * @param string $crcHash
135
     */
136 94
    public function setCrcHash($crcHash)
137
    {
138 94
        $this->crcHash = $crcHash;
139
140 94
        return $this;
141
    }
142
143
    /**
144
     * @return int
145
     */
146 47
    public function getDelay()
147
    {
148 47
        return $this->delay;
149
    }
150
151
    /**
152
     * @param int $delay Delay in seconds
153
     */
154 29
    public function setDelay($delay)
155
    {
156 29
        $this->delay = $delay;
157
158 29
        return $this;
159
    }
160
161
    /**
162
     * @return mixed
163
     */
164 22
    public function getRunId()
165
    {
166 22
        return $this->runId;
167
    }
168
169
    /**
170
     * @param mixed $runId
171
     */
172 21
    public function setRunId($runId)
173
    {
174 21
        $this->runId = $runId;
175
176 21
        return $this;
177
    }
178
179
    /**
180
     * @return \DateTime|null
181
     */
182 40
    public function getFinishedAt()
183
    {
184 40
        return $this->finishedAt;
185
    }
186
187
    /**
188
     * @param \DateTime|null $finishedAt
189
     */
190 23
    public function setFinishedAt($finishedAt)
191
    {
192 23
        $this->finishedAt = $finishedAt;
193
194 23
        return $this;
195
    }
196
197
    /**
198
     * @return int
199
     */
200 41
    public function getElapsed()
201
    {
202 41
        return $this->elapsed;
203
    }
204
205
    /**
206
     * @param int $elapsed
207
     */
208 23
    public function setElapsed($elapsed)
209
    {
210 23
        $this->elapsed = $elapsed;
211
212 23
        return $this;
213
    }
214
}
215