Completed
Push — master ( cdd718...8a683b )
by Matthew
06:43 queued 30s
created

Job::__call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 6
cts 7
cp 0.8571
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
crap 2.0116
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 $locked;
13
    protected $lockedAt;
14
    protected $expiresAt;
15
    protected $delay;
16
    protected $startedAt;
17
    protected $finishedAt;
18
    protected $maxDuration;
19
    protected $elapsed;
20
    protected $runId;
21
22 5
    public function __call($method, $args)
23
    {
24 5
        $this->method = $method;
25 5
        $this->setArgs($args);
26
27
        // Make sure the method exists - job should not be created
28 5
        if (!method_exists($this->worker, $method)) {
29
            throw new \BadMethodCallException("{$this->className}->{$method}() does not exist");
30
        }
31
32 5
        $job = $this->jobManager->save($this);
33
34 5
        return $job;
35
    }
36
37
    /**
38
     * @return string|null
39
     */
40 2
    public function getMessage()
41
    {
42 2
        return $this->message;
43
    }
44
45
    /**
46
     * @param string $message
47
     */
48 1
    public function setMessage($message)
49
    {
50 1
        $this->message = $message;
51
52 1
        return $this;
53
    }
54
55
    /**
56
     * @return bool|null
57
     */
58 2
    public function getLocked()
59
    {
60 2
        return $this->locked;
61
    }
62
63
    /**
64
     * @return \DateTime|null
65
     */
66 2
    public function getLockedAt()
67
    {
68 2
        return $this->lockedAt;
69
    }
70
71
    /**
72
     * @return \DateTime|null
73
     */
74 6
    public function getExpiresAt()
75
    {
76 6
        return $this->expiresAt;
77
    }
78
79
    /**
80
     * @param bool|null $locked
81
     */
82 2
    public function setLocked($locked)
83
    {
84 2
        $this->locked = $locked;
85
86 2
        return $this;
87
    }
88
89
    /**
90
     * @param \DateTime|null $lockedAt
91
     */
92 1
    public function setLockedAt($lockedAt)
93
    {
94 1
        $this->lockedAt = $lockedAt;
95
96 1
        return $this;
97
    }
98
99
    /**
100
     * @param \DateTime $expiresAt
101
     */
102 2
    public function setExpiresAt(\DateTime $expiresAt)
103
    {
104 2
        $this->expiresAt = $expiresAt;
105
106 2
        return $this;
107
    }
108
109
    /**
110
     * @return int
111
     */
112 5
    public function getId()
113
    {
114 5
        return $this->id;
115
    }
116
117
    /**
118
     * @return string
119
     */
120 2
    public function getCrcHash()
121
    {
122 2
        return $this->crcHash;
123
    }
124
125
    /**
126
     * @param mixed $id
127
     */
128 6
    public function setId($id)
129
    {
130 6
        $this->id = $id;
131
132 6
        return $this;
133
    }
134
135
    /**
136
     * @return \DateTime|null
137
     */
138 1
    public function getStartedAt()
139
    {
140 1
        return $this->startedAt;
141
    }
142
143
    /**
144
     * @param \DateTime|null $startedAt
145
     */
146
    public function setStartedAt(\DateTime $startedAt = null)
147
    {
148
        $this->startedAt = $startedAt;
149
150
        return $this;
151
    }
152
153
    /**
154
     * @return \DateTime|null
155
     */
156 2
    public function getFinishedAt()
157
    {
158 2
        return $this->finishedAt;
159
    }
160
161
    /**
162
     * @param \DateTime|null $finishedAt
163
     */
164 1
    public function setFinishedAt($finishedAt)
165
    {
166 1
        $this->finishedAt = $finishedAt;
167
168 1
        return $this;
169
    }
170
171
    /**
172
     * @return int|null
173
     */
174 2
    public function getMaxDuration()
175
    {
176 2
        return $this->maxDuration;
177
    }
178
179
    /**
180
     * @param int|null $maxDuration
181
     */
182 1
    public function setMaxDuration($maxDuration)
183
    {
184 1
        $this->maxDuration = $maxDuration;
185
186 1
        return $this;
187
    }
188
189
    /**
190
     * @param string $crcHash
191
     */
192 2
    public function setCrcHash($crcHash)
193
    {
194 2
        $this->crcHash = $crcHash;
195
196 2
        return $this;
197
    }
198
199
    /**
200
     * @param JobManagerInterface $jobManager
201
     */
202 1
    public function setJobManager(JobManagerInterface $jobManager)
203
    {
204 1
        $this->jobManager = $jobManager;
205
206 1
        return $this;
207
    }
208
209
    /**
210
     * @return int
211
     */
212 6
    public function getDelay()
213
    {
214 6
        return $this->delay;
215
    }
216
217
    /**
218
     * @param int $delay Delay in seconds
219
     */
220 3
    public function setDelay($delay)
221
    {
222 3
        $this->delay = $delay;
223
224 3
        return $this;
225
    }
226
227
    /**
228
     * @return int
229
     */
230 2
    public function getElapsed()
231
    {
232 2
        return $this->elapsed;
233
    }
234
235
    /**
236
     * @param int $elapsed
237
     */
238 1
    public function setElapsed($elapsed)
239
    {
240 1
        $this->elapsed = $elapsed;
241
242 1
        return $this;
243
    }
244
245
    /**
246
     * @return mixed
247
     */
248 2
    public function getRunId()
249
    {
250 2
        return $this->runId;
251
    }
252
253
    /**
254
     * @param mixed $runId
255
     */
256 4
    public function setRunId($runId)
257
    {
258 4
        $this->runId = $runId;
259
260 4
        return $this;
261
    }
262
}
263