BatchConnector::connect()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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\Connectors;
13
14
use Aws\Batch\BatchClient;
15
use Illuminate\Queue\Connectors\DatabaseConnector;
16
use Illuminate\Support\Arr;
17
use DNXLabs\LaravelQueueAwsBatch\Queues\BatchQueue;
18
19
class BatchConnector extends DatabaseConnector
20
{
21
    /**
22
     * Establish a queue connection.
23
     *
24
     * @param array $config
25
     *
26
     * @return \Illuminate\Contracts\Queue\Queue
27
     */
28
    public function connect(array $config)
29
    {
30
        return new BatchQueue(
31
            $this->connections->connection(Arr::get($config, 'connection')),
32
            $config['table'],
33
            $config['queue'],
34
            Arr::get($config, 'expire', 60),
35
            $config['jobDefinition'],
36
            new BatchClient([
37
                'region'  => $config['region'],
38
                'version' => '2016-08-10',
39
            ])
40
        );
41
    }
42
}
43