From 3433364d55701e7a5c9c8b8e3a29eb778587d263 Mon Sep 17 00:00:00 2001 From: prolic Date: Thu, 15 Nov 2018 22:18:23 +0800 Subject: [PATCH 1/2] fix connection string usage --- src/ConnectionString.php | 4 ---- src/EventStoreAsyncConnectionFactory.php | 8 ++++---- src/EventStoreSyncConnectionFactory.php | 8 ++++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/ConnectionString.php b/src/ConnectionString.php index 8ea1359b..af1ca117 100644 --- a/src/ConnectionString.php +++ b/src/ConnectionString.php @@ -154,10 +154,6 @@ public static function getUriFromConnectionString(string $connectionString): ?Ur { $values = \explode(';', $connectionString); - if (1 === \count($values)) { - return Uri::fromString($connectionString); - } - foreach ($values as $value) { list($key, $value) = \explode('=', $value); diff --git a/src/EventStoreAsyncConnectionFactory.php b/src/EventStoreAsyncConnectionFactory.php index 0612b699..87868966 100644 --- a/src/EventStoreAsyncConnectionFactory.php +++ b/src/EventStoreAsyncConnectionFactory.php @@ -25,7 +25,7 @@ class EventStoreAsyncConnectionFactory public static function createFromConnectionString( string $connectionString, ConnectionSettings $settings = null, - string $connectionName = '' + ?string $connectionName = null ): AsyncConnection { $settings = ConnectionString::getConnectionSettings( $connectionString, @@ -52,7 +52,7 @@ public static function createFromConnectionString( public static function createFromUri( ?Uri $uri, ?ConnectionSettings $connectionSettings = null, - string $connectionName = '' + ?string $connectionName = null ): AsyncConnection { $connectionSettings = $connectionSettings ?? ConnectionSettings::default(); @@ -141,7 +141,7 @@ public static function createFromUri( public static function createFromEndPoint( EndPoint $endPoint, ?ConnectionSettings $settings = null, - string $connectionName = '' + ?string $connectionName = null ): AsyncConnection { $settings = $settings ?? ConnectionSettings::default(); @@ -158,7 +158,7 @@ public static function createFromEndPoint( public static function createFromSettings( ConnectionSettings $settings, - string $connectionName = '' + ?string $connectionName = null ): AsyncConnection { return self::createFromUri(null, $settings, $connectionName); } diff --git a/src/EventStoreSyncConnectionFactory.php b/src/EventStoreSyncConnectionFactory.php index bcff9918..20e29d82 100644 --- a/src/EventStoreSyncConnectionFactory.php +++ b/src/EventStoreSyncConnectionFactory.php @@ -25,7 +25,7 @@ class EventStoreSyncConnectionFactory public static function createFromConnectionString( string $connectionString, ConnectionSettings $settings = null, - string $connectionName = '' + ?string $connectionName = null ): SyncConnection { $settings = ConnectionString::getConnectionSettings( $connectionString, @@ -52,7 +52,7 @@ public static function createFromConnectionString( public static function createFromUri( ?Uri $uri, ?ConnectionSettings $connectionSettings = null, - string $connectionName = '' + ?string $connectionName = null ): SyncConnection { $connectionSettings = $connectionSettings ?? ConnectionSettings::default(); @@ -141,7 +141,7 @@ public static function createFromUri( public static function createFromEndPoint( EndPoint $endPoint, ?ConnectionSettings $settings = null, - string $connectionName = '' + ?string $connectionName = null ): SyncConnection { $settings = $settings ?? ConnectionSettings::default(); @@ -158,7 +158,7 @@ public static function createFromEndPoint( public static function createFromSettings( ConnectionSettings $settings, - string $connectionName = '' + ?string $connectionName = null ): SyncConnection { return self::createFromUri(null, $settings, $connectionName); } From e3982b4eebee4b516d598c3446f8c2a065258811 Mon Sep 17 00:00:00 2001 From: prolic Date: Thu, 15 Nov 2018 22:18:46 +0800 Subject: [PATCH 2/2] apply php cs fix --- src/ConnectionString.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ConnectionString.php b/src/ConnectionString.php index af1ca117..fc11b7f6 100644 --- a/src/ConnectionString.php +++ b/src/ConnectionString.php @@ -60,7 +60,7 @@ public static function getConnectionSettings( if ('connectto' === $key) { continue; } - + if (! \array_key_exists($key, self::$allowedValues)) { throw new InvalidArgumentException(\sprintf( 'Key %s is not an allowed key in %s',