Conditions | 4 |
Paths | 3 |
Total Lines | 28 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 20 |
CRAP Score | 4 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | 120 | public function connect(array $config) |
|
22 | { |
||
23 | 120 | $config = $this->getDefaultConfiguration($config); |
|
24 | |||
25 | 120 | if (!Str::endsWith($config['queue'], '.fifo')) { |
|
26 | 5 | throw new InvalidArgumentException('FIFO queue name must end in ".fifo"'); |
|
27 | } |
||
28 | |||
29 | 115 | if (!empty($config['key']) && !empty($config['secret'])) { |
|
30 | 100 | $config['credentials'] = Arr::only($config, ['key', 'secret', 'token']); |
|
31 | } |
||
32 | |||
33 | // Pull the custom config options out of the config array sent to SqsClient. |
||
34 | 115 | $group = Arr::pull($config, 'group', 'default'); |
|
35 | 115 | $deduplicator = Arr::pull($config, 'deduplicator', 'unique'); |
|
36 | 115 | $allowDelay = (bool)Arr::pull($config, 'allow_delay', false); |
|
37 | |||
38 | 115 | return new SqsFifoQueue( |
|
39 | 115 | new SqsClient( |
|
40 | 115 | Arr::except($config, ['token']) |
|
41 | 115 | ), |
|
42 | 115 | $config['queue'], |
|
43 | 115 | $config['prefix'] ?? '', |
|
44 | 115 | $config['suffix'] ?? '', |
|
45 | 115 | (bool)($config['after_commit'] ?? null), |
|
46 | 115 | $group, |
|
47 | 115 | $deduplicator, |
|
48 | 115 | $allowDelay |
|
49 | 115 | ); |
|
52 |