Skip to content

Commit 087eeb5

Browse files
committed
Move client passed to SqsConnectionFactory out of config array
1 parent f72e2ec commit 087eeb5

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

docs/transport/sqs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $psrContext = $factory->createContext();
3636

3737
// using a pre-configured client
3838
$client = new Aws\Sqs\SqsClient([ /* ... */ ]);
39-
$factory = new SqsConnectionFactory(['client' => $client]);
39+
$factory = new SqsConnectionFactory($client);
4040

4141
// if you have enqueue/enqueue library installed you can use a function from there to create the context
4242
$psrContext = \Enqueue\dsn_to_context('sqs:');

pkg/sqs/SqsConnectionFactory.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class SqsConnectionFactory implements PsrConnectionFactory
1919

2020
/**
2121
* $config = [
22-
* 'client' => null, - Pre-configured instance of Aws\Sqs\SqsClient. If provided, all other settings except for 'lazy' are ignored.
2322
* 'key' => null - AWS credentials. If no credentials are provided, the SDK will attempt to load them from the environment.
2423
* 'secret' => null, - AWS credentials. If no credentials are provided, the SDK will attempt to load them from the environment.
2524
* 'token' => null, - AWS credentials. If no credentials are provided, the SDK will attempt to load them from the environment.
@@ -35,12 +34,12 @@ class SqsConnectionFactory implements PsrConnectionFactory
3534
* sqs:
3635
* sqs::?key=aKey&secret=aSecret&token=aToken
3736
*
38-
* @param array|string|null $config
37+
* @param array|string|SqsClient|null $config
3938
*/
4039
public function __construct($config = 'sqs:')
4140
{
42-
if (is_array($config) && isset($config['client']) && $config['client'] instanceof SqsClient) {
43-
$this->client = $config['client'];
41+
if ($config instanceof SqsClient) {
42+
return $this->client = $config;
4443
} elseif (empty($config) || 'sqs:' === $config) {
4544
$config = [];
4645
} elseif (is_string($config)) {

pkg/sqs/Tests/SqsConnectionFactoryTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ public function testCouldBeConstructedWithClient()
5353
{
5454
$client = $this->createMock(SqsClient::class);
5555

56-
$factory = new SqsConnectionFactory([
57-
'client' => $client,
58-
'lazy' => false,
59-
]);
56+
$factory = new SqsConnectionFactory($client);
6057

6158
$context = $factory->createContext();
6259

0 commit comments

Comments
 (0)