Passed
Pull Request — main (#42)
by Luke
09:39
created

BatchJob::release()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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