Completed
Push — master ( e28c79...14b414 )
by Avtandil
02:36
created

SqsFifoConnector::connect()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 17
c 0
b 0
f 0
nc 4
nop 1
dl 0
loc 25
ccs 0
cts 21
cp 0
crap 20
rs 8.5806
1
<?php
2
/*
3
 * This file is part of the Laravel Lodash package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
declare(strict_types=1);
11
12
namespace Longman\LaravelLodash\Queue\SqsFifo\Connectors;
13
14
use Longman\LaravelLodash\Queue\SqsFifo\SqsFifoQueue;
15
use Aws\Sqs\SqsClient;
16
use Illuminate\Queue\Connectors\SqsConnector;
17
use Illuminate\Queue\SqsQueue;
18
use Illuminate\Support\Arr;
19
20
class SqsFifoConnector extends SqsConnector
21
{
22
    /**
23
     * Establish a queue connection.
24
     *
25
     * @param  array $config
26
     * @return \Illuminate\Contracts\Queue\Queue
27
     */
28
    public function connect(array $config)
29
    {
30
        $config = $this->getDefaultConfiguration($config);
31
32
        if ($config['key'] && $config['secret']) {
33
            $config['credentials'] = Arr::only($config, ['key', 'secret']);
34
        }
35
36
        $options = $config['options'] ?? [];
37
        unset($config['options']);
38
39
        $queue = Arr::get($options, 'type') === 'fifo' ? new SqsFifoQueue(
40
            new SqsClient($config),
41
            $config['queue'],
42
            $config['prefix'] ?? '',
43
            $options
44
        ) : new SqsQueue(
45
            new SqsClient($config),
46
            $config['queue'],
47
            $config['prefix'] ?? '',
48
            $options
0 ignored issues
show
Unused Code introduced by
The call to SqsQueue::__construct() has too many arguments starting with $options.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
49
        );
50
51
        return $queue;
52
    }
53
}
54