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

SqsFifoConnector   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 34
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 5
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