BatchJob::release()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
ccs 3
cts 5
cp 0.6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.2559
1
<?php
2
/**
3
 * Laravel Queue for AWS Batch.
4
 *
5
 * @author    Luke Waite <[email protected]>
6
 * @copyright 2017 Luke Waite
7
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
8
 *
9
 * @link      https://github.com/dnxlabs/laravel-queue-aws-batch
10
 */
11
12
namespace DNXLabs\LaravelQueueAwsBatch\Jobs;
13
14
use Illuminate\Queue\Jobs\DatabaseJob;
15
use DNXLabs\LaravelQueueAwsBatch\Exceptions\UnsupportedException;
16
17
class BatchJob extends DatabaseJob
18
{
19
    /**
20
     * The database queue instance.
21
     *
22
     * @var \DNXLabs\LaravelQueueAwsBatch\Queues\BatchQueue
23
     */
24
    protected $database;
25
26
    /**
27
     * Release the job back into the queue.
28
     *
29
     * Here we need to retain the same jobId, so Batch can retry it, so we need to override the parent.
30
     *
31
     * @param int $delay
32
     *
33
     * @return void
34
     * @throws UnsupportedException
35
     */
36 1
    public function release($delay = 0)
37
    {
38 1
        if ($delay != 0) {
39 1
            throw new UnsupportedException('The BatchJob does not support releasing back onto the queue with a delay');
40
        }
41
42
        $this->released = true;
43
44
        $this->database->release($this->queue, $this->job, 0);
45
    }
46
}
47