Completed
Pull Request — master (#30)
by Matthew
16:57
created

Job::getCrcHash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

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