Completed
Push — master ( efafaa...1ce8a3 )
by Avtandil
05:26
created

SqsFifoConnector::connect()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 1
dl 0
loc 25
ccs 0
cts 15
cp 0
crap 20
rs 9.52
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Longman\LaravelLodash\Queue\SqsFifo\Connectors;
6
7
use Aws\Sqs\SqsClient;
8
use Illuminate\Queue\Connectors\SqsConnector;
9
use Illuminate\Queue\SqsQueue;
10
use Illuminate\Support\Arr;
11
use Longman\LaravelLodash\Queue\SqsFifo\SqsFifoQueue;
12
13
class SqsFifoConnector extends SqsConnector
14
{
15
    /**
16
     * Establish a queue connection.
17
     *
18
     * @param  array $config
19
     * @return \Illuminate\Contracts\Queue\Queue
20
     */
21
    public function connect(array $config)
22
    {
23
        $config = $this->getDefaultConfiguration($config);
24
25
        if ($config['key'] && $config['secret']) {
26
            $config['credentials'] = Arr::only($config, ['key', 'secret']);
27
        }
28
29
        $options = $config['options'] ?? [];
30
        unset($config['options']);
31
32
        $queue = Arr::get($options, 'type') === 'fifo' ? new SqsFifoQueue(
33
            new SqsClient($config),
34
            $config['queue'],
35
            $config['prefix'] ?? '',
36
            $options,
37
        ) : new SqsQueue(
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected ')'
Loading history...
38
            new SqsClient($config),
39
            $config['queue'],
40
            $config['prefix'] ?? '',
41
            $options,
42
        );
43
44
        return $queue;
45
    }
46
}
47