Skip to content

Commit 050062e

Browse files
authored
Use snake_case for configuration options (#11)
1 parent af4da33 commit 050062e

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ mongodb:
5555
clients:
5656
default:
5757
uri: '%env(MONGODB_URI)%'
58-
uriOptions: #...
59-
driverOptions: #...
58+
uri_options: #...
59+
driver_options: #...
6060
```
6161

62-
The `uriOptions` and `driverOptions` are passed directly to the underlying MongoDB driver.
62+
The `uri_options` and `driver_options` are passed directly to the underlying MongoDB driver.
6363
See the [documentation](https://www.php.net/manual/en/mongodb-driver-manager.construct.php) for available options.
6464

6565
If you want to configure multiple clients, you can do so by adding additional clients to the configuration:

src/DependencyInjection/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public function getConfigTreeBuilder(): TreeBuilder
3232
->scalarNode('uri')
3333
->info('MongoDB connection string')
3434
->end()
35-
->arrayNode('uriOptions')
35+
->arrayNode('uri_options')
3636
->info('Additional connection string options')
3737
->variablePrototype()->end()
3838
->end()
39-
->arrayNode('driverOptions')
39+
->arrayNode('driver_options')
4040
->info('Driver-specific options')
4141
->variablePrototype()->end()
4242
->end()

src/DependencyInjection/MongoDBExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ private function createClients(string $defaultClient, array $clients, ContainerB
6868

6969
$clientDefinition = clone $clientPrototype;
7070
$clientDefinition->setArgument('$uri', $configuration['uri']);
71-
$clientDefinition->setArgument('$uriOptions', $configuration['uriOptions'] ?? []);
72-
$clientDefinition->setArgument('$driverOptions', $configuration['driverOptions'] ?? []);
71+
$clientDefinition->setArgument('$uriOptions', $configuration['uri_options'] ?? []);
72+
$clientDefinition->setArgument('$driverOptions', $configuration['driver_options'] ?? []);
7373

7474
$container->setDefinition($serviceId, $clientDefinition);
7575

tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public function testProcess(): void
3838
[
3939
'id' => 'default',
4040
'uri' => 'mongodb://localhost:27017',
41-
'uriOptions' => ['readPreference' => 'primary'],
41+
'uri_options' => ['readPreference' => 'primary'],
4242
],
4343
[
4444
'id' => 'secondary',
4545
'uri' => 'mongodb://localhost:27018',
46-
'driverOptions' => ['serverApi' => new ServerApi((string) ServerApi::V1)],
46+
'driver_options' => ['serverApi' => new ServerApi((string) ServerApi::V1)],
4747
],
4848
],
4949
],
@@ -58,13 +58,13 @@ public function testProcess(): void
5858

5959
$this->assertArrayHasKey('default', $clients);
6060
$this->assertSame('mongodb://localhost:27017', $clients['default']['uri']);
61-
$this->assertSame(['readPreference' => 'primary'], $clients['default']['uriOptions']);
62-
$this->assertSame([], $clients['default']['driverOptions']);
61+
$this->assertSame(['readPreference' => 'primary'], $clients['default']['uri_options']);
62+
$this->assertSame([], $clients['default']['driver_options']);
6363

6464
$this->assertArrayHasKey('secondary', $clients);
6565
$this->assertSame('mongodb://localhost:27018', $clients['secondary']['uri']);
66-
$this->assertSame([], $clients['secondary']['uriOptions']);
67-
$this->assertEquals(['serverApi' => new ServerApi((string) ServerApi::V1)], $clients['secondary']['driverOptions']);
66+
$this->assertSame([], $clients['secondary']['uri_options']);
67+
$this->assertEquals(['serverApi' => new ServerApi((string) ServerApi::V1)], $clients['secondary']['driver_options']);
6868
}
6969

7070
public function testProcessWithYamlFile(): void
@@ -74,11 +74,11 @@ public function testProcessWithYamlFile(): void
7474
clients:
7575
default:
7676
uri: mongodb://localhost:27017
77-
uriOptions:
77+
uri_options:
7878
readPreference: primary
7979
secondary:
8080
uri: mongodb://localhost:27018
81-
driverOptions:
81+
driver_options:
8282
serverApi: v1
8383
YAML);
8484

@@ -91,13 +91,13 @@ public function testProcessWithYamlFile(): void
9191

9292
$this->assertArrayHasKey('default', $clients);
9393
$this->assertSame('mongodb://localhost:27017', $clients['default']['uri']);
94-
$this->assertSame(['readPreference' => 'primary'], $clients['default']['uriOptions']);
95-
$this->assertSame([], $clients['default']['driverOptions']);
94+
$this->assertSame(['readPreference' => 'primary'], $clients['default']['uri_options']);
95+
$this->assertSame([], $clients['default']['driver_options']);
9696

9797
$this->assertArrayHasKey('secondary', $clients);
9898
$this->assertSame('mongodb://localhost:27018', $clients['secondary']['uri']);
99-
$this->assertSame([], $clients['secondary']['uriOptions']);
100-
$this->assertSame(['serverApi' => 'v1'], $clients['secondary']['driverOptions']);
99+
$this->assertSame([], $clients['secondary']['uri_options']);
100+
$this->assertSame(['serverApi' => 'v1'], $clients['secondary']['driver_options']);
101101
}
102102

103103
public function testProcessWithYamlFileWithoutUriKey(): void

tests/Unit/DependencyInjection/MongoDBExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ public function testLoadWithMultipleClients(): void
7575
[
7676
'id' => 'default',
7777
'uri' => 'mongodb://localhost:27017',
78-
'uriOptions' => ['readPreference' => 'primary'],
78+
'uri_options' => ['readPreference' => 'primary'],
7979
],
8080
[
8181
'id' => 'secondary',
8282
'uri' => 'mongodb://localhost:27018',
83-
'driverOptions' => ['serverApi' => new ServerApi((string) ServerApi::V1)],
83+
'driver_options' => ['serverApi' => new ServerApi((string) ServerApi::V1)],
8484
],
8585
],
8686
],

0 commit comments

Comments
 (0)