| 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 | 216 | public function connect(array $config) |
|
| 22 | { |
||
| 23 | 216 | $config = $this->getDefaultConfiguration($config); |
|
| 24 | |||
| 25 | 216 | if (!Str::endsWith($config['queue'], '.fifo')) { |
|
| 26 | 9 | throw new InvalidArgumentException('FIFO queue name must end in ".fifo"'); |
|
| 27 | } |
||
| 28 | |||
| 29 | 207 | if (!empty($config['key']) && !empty($config['secret'])) { |
|
| 30 | 180 | $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 | 207 | $group = Arr::pull($config, 'group', 'default'); |
|
| 35 | 207 | $deduplicator = Arr::pull($config, 'deduplicator', 'unique'); |
|
| 36 | 207 | $allowDelay = (bool)Arr::pull($config, 'allow_delay', false); |
|
| 37 | |||
| 38 | 207 | return new SqsFifoQueue( |
|
| 39 | 207 | new SqsClient( |
|
| 40 | 207 | Arr::except($config, ['token']) |
|
| 41 | 207 | ), |
|
| 42 | 207 | $config['queue'], |
|
| 43 | 207 | $config['prefix'] ?? '', |
|
| 44 | 207 | $config['suffix'] ?? '', |
|
| 45 | 207 | (bool)($config['after_commit'] ?? null), |
|
| 46 | 207 | $group, |
|
| 47 | 207 | $deduplicator, |
|
| 48 | 207 | $allowDelay |
|
| 49 | 207 | ); |
|
| 52 |