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

BatchJob   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
eloc 6
c 2
b 1
f 0
dl 0
loc 28
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A release() 0 9 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