Job::setId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Loevgaard\CronBundle\Entity;
4
5
use Cron\CronExpression;
6
use Doctrine\ORM\Mapping as ORM;
7
use Loevgaard\CronBundle\Validator\Constraints\ValidCronExpression;
8
use Symfony\Component\Validator\Constraints as Assert;
9
10
/**
11
 * @ORM\Entity(repositoryClass="JobRepository")
12
 */
13
class Job implements JobInterface
14
{
15
    /**
16
     * @var int
17
     *
18
     * @ORM\Column(type="integer")
19
     * @ORM\GeneratedValue(strategy="AUTO")
20
     * @ORM\Id
21
     */
22
    protected $id;
23
24
    /**
25
     * The name of the job. Only used as a reference.
26
     *
27
     * @var string
28
     *
29
     * @Assert\NotBlank()
30
     * @Assert\Length(max="191")
31
     *
32
     * @ORM\Column(type="string", length=191)
33
     */
34
    protected $name;
35
36
    /**
37
     * Description of the job. Only used as a reference.
38
     *
39
     * @var string
40
     *
41
     * @ORM\Column(type="text", nullable=true)
42
     */
43
    protected $description;
44
45
    /**
46
     * @var string
47
     *
48
     * @Assert\NotBlank()
49
     * @Assert\Length(max="191")
50
     *
51
     * @ORM\Column(type="string", length=191)
52
     */
53
    protected $command;
54
55
    /**
56
     * @var string
57
     *
58
     * @Assert\Length(max="191")
59
     *
60
     * @ORM\Column(type="string", length=191, nullable=true)
61
     */
62
    protected $arguments;
63
64
    /**
65
     * @var int
66
     *
67
     * @Assert\GreaterThanOrEqual(0)
68
     *
69
     * @ORM\Column(type="int")
70
     */
71
    protected $idleTimeout;
72
73
    /**
74
     * @var int
75
     *
76
     * @Assert\GreaterThanOrEqual(0)
77
     *
78
     * @ORM\Column(type="int")
79
     */
80
    protected $timeout;
81
82
    /**
83
     * @var CronExpression
84
     *
85
     * @Assert\NotBlank()
86
     * @ValidCronExpression
87
     *
88
     * @ORM\Column(type="cron_expression")
89
     */
90
    protected $cronExpression;
91
92
    /**
93
     * The output log.
94
     *
95
     * @var string
96
     *
97
     * @Assert\NotBlank()
98
     * @Assert\Length(max="191")
99
     *
100
     * @ORM\Column(type="string", length=191)
101
     */
102
    protected $log;
103
104
    /**
105
     * The error log.
106
     *
107
     * @var string
108
     *
109
     * @Assert\NotBlank()
110
     * @Assert\Length(max="191")
111
     *
112
     * @ORM\Column(type="string", length=191)
113
     */
114
    protected $errorLog;
115
116
    /**
117
     * @var bool
118
     *
119
     * @ORM\Column(type="boolean")
120
     */
121
    protected $enabled;
122
123
    /**
124
     * If true, this job will only allow a single process to run at a time.
125
     *
126
     * @var bool
127
     *
128
     * @ORM\Column(type="boolean")
129
     */
130
    protected $singleProcess;
131
132
    /**
133
     * The pid of the last started process.
134
     *
135
     * @var int
136
     *
137
     * @ORM\Column(type="integer", nullable=true)
138
     */
139
    protected $pid;
140
141
    public function __construct()
142
    {
143
        $this->enabled = false;
144
        $this->singleProcess = false;
145
    }
146
147
    /**
148
     * {@inheritdoc}
149
     */
150
    public function getId()
151
    {
152
        return $this->id;
153
    }
154
155
    /**
156
     * {@inheritdoc}
157
     */
158
    public function setId(int $id): JobInterface
159
    {
160
        $this->id = $id;
161
162
        return $this;
163
    }
164
165
    /**
166
     * {@inheritdoc}
167
     */
168
    public function getName(): string
169
    {
170
        return $this->name;
171
    }
172
173
    /**
174
     * {@inheritdoc}
175
     */
176
    public function setName(string $name): JobInterface
177
    {
178
        $this->name = $name;
179
180
        return $this;
181
    }
182
183
    /**
184
     * {@inheritdoc}
185
     */
186
    public function getDescription(): string
187
    {
188
        return $this->description;
189
    }
190
191
    /**
192
     * {@inheritdoc}
193
     */
194
    public function setDescription(string $description): JobInterface
195
    {
196
        $this->description = $description;
197
198
        return $this;
199
    }
200
201
    /**
202
     * {@inheritdoc}
203
     */
204
    public function getCommand(): string
205
    {
206
        return $this->command;
207
    }
208
209
    /**
210
     * {@inheritdoc}
211
     */
212
    public function setCommand(string $command): JobInterface
213
    {
214
        $this->command = $command;
215
216
        return $this;
217
    }
218
219
    /**
220
     * {@inheritdoc}
221
     */
222
    public function getArguments(): string
223
    {
224
        return $this->arguments;
225
    }
226
227
    /**
228
     * {@inheritdoc}
229
     */
230
    public function setArguments(string $arguments): JobInterface
231
    {
232
        $this->arguments = $arguments;
233
234
        return $this;
235
    }
236
237
    /**
238
     * {@inheritdoc}
239
     */
240
    public function getIdleTimeout(): int
241
    {
242
        return $this->idleTimeout;
243
    }
244
245
    /**
246
     * {@inheritdoc}
247
     */
248
    public function setIdleTimeout(int $idleTimeout): JobInterface
249
    {
250
        $this->idleTimeout = $idleTimeout;
251
252
        return $this;
253
    }
254
255
    /**
256
     * {@inheritdoc}
257
     */
258
    public function getTimeout(): int
259
    {
260
        return $this->timeout;
261
    }
262
263
    /**
264
     * {@inheritdoc}
265
     */
266
    public function setTimeout(int $timeout): JobInterface
267
    {
268
        $this->timeout = $timeout;
269
270
        return $this;
271
    }
272
273
    /**
274
     * {@inheritdoc}
275
     */
276
    public function getCronExpression(): CronExpression
277
    {
278
        return $this->cronExpression;
279
    }
280
281
    /**
282
     * {@inheritdoc}
283
     */
284
    public function setCronExpression(CronExpression $cronExpression): JobInterface
285
    {
286
        $this->cronExpression = $cronExpression;
287
288
        return $this;
289
    }
290
291
    /**
292
     * {@inheritdoc}
293
     */
294
    public function getLog(): string
295
    {
296
        return $this->log;
297
    }
298
299
    /**
300
     * {@inheritdoc}
301
     */
302
    public function setLog(string $log): JobInterface
303
    {
304
        $this->log = $log;
305
306
        return $this;
307
    }
308
309
    /**
310
     * {@inheritdoc}
311
     */
312
    public function getErrorLog(): string
313
    {
314
        return $this->errorLog;
315
    }
316
317
    /**
318
     * {@inheritdoc}
319
     */
320
    public function setErrorLog(string $errorLog): JobInterface
321
    {
322
        $this->errorLog = $errorLog;
323
324
        return $this;
325
    }
326
327
    /**
328
     * {@inheritdoc}
329
     */
330
    public function isEnabled(): bool
331
    {
332
        return $this->enabled;
333
    }
334
335
    /**
336
     * {@inheritdoc}
337
     */
338
    public function setEnabled(bool $enabled): JobInterface
339
    {
340
        $this->enabled = $enabled;
341
342
        return $this;
343
    }
344
345
    /**
346
     * {@inheritdoc}
347
     */
348
    public function isSingleProcess(): bool
349
    {
350
        return $this->singleProcess;
351
    }
352
353
    /**
354
     * {@inheritdoc}
355
     */
356
    public function setSingleProcess(bool $singleProcess): JobInterface
357
    {
358
        $this->singleProcess = $singleProcess;
359
360
        return $this;
361
    }
362
363
    /**
364
     * {@inheritdoc}
365
     */
366
    public function getPid(): int
367
    {
368
        return $this->pid;
369
    }
370
371
    /**
372
     * {@inheritdoc}
373
     */
374
    public function setPid(int $pid): JobInterface
375
    {
376
        $this->pid = $pid;
377
378
        return $this;
379
    }
380
}
381