From d8f889391659c3e8a247274497329514f462f834 Mon Sep 17 00:00:00 2001 From: Ghlen Nagels Date: Wed, 20 Sep 2023 11:56:05 -0400 Subject: [PATCH] add hasDriver method --- src/Basic/Client.php | 5 +++++ src/Client.php | 5 +++++ src/Common/DriverSetupManager.php | 5 +++++ src/Contracts/ClientInterface.php | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/src/Basic/Client.php b/src/Basic/Client.php index e3afc0ff..3833b658 100644 --- a/src/Basic/Client.php +++ b/src/Basic/Client.php @@ -58,6 +58,11 @@ public function getDriver(?string $alias): DriverInterface return $this->client->getDriver($alias); } + public function hasDriver(string $alias): bool + { + return $this->client->hasDriver($alias); + } + public function writeTransaction(callable $tsxHandler, ?string $alias = null, ?TransactionConfiguration $config = null) { return $this->client->writeTransaction($tsxHandler, $alias, $config); diff --git a/src/Client.php b/src/Client.php index 53a31855..5a3e4b4e 100644 --- a/src/Client.php +++ b/src/Client.php @@ -153,6 +153,11 @@ public function verifyConnectivity(?string $driver = null): bool return $this->driverSetups->verifyConnectivity($this->defaultSessionConfiguration, $driver); } + public function hasDriver(string $alias): bool + { + return $this->driverSetups->hasDriver($alias); + } + public function bindTransaction(?string $alias = null, ?TransactionConfiguration $config = null): void { $alias ??= $this->driverSetups->getDefaultAlias(); diff --git a/src/Common/DriverSetupManager.php b/src/Common/DriverSetupManager.php index 8b9a6ec0..f954df67 100644 --- a/src/Common/DriverSetupManager.php +++ b/src/Common/DriverSetupManager.php @@ -77,6 +77,11 @@ public function withSetup(DriverSetup $setup, ?string $alias = null, ?int $prior return $tbr; } + public function hasDriver(string $alias): bool + { + return array_key_exists($alias, $this->driverSetups); + } + /** * @return DriverInterface */ diff --git a/src/Contracts/ClientInterface.php b/src/Contracts/ClientInterface.php index 7185ebf6..5a5f1d4c 100644 --- a/src/Contracts/ClientInterface.php +++ b/src/Contracts/ClientInterface.php @@ -76,6 +76,11 @@ public function beginTransaction(?iterable $statements = null, ?string $alias = */ public function getDriver(?string $alias): DriverInterface; + /** + * Checks to see if the Client has the driver registered with the provided alias. + */ + public function hasDriver(string $alias): bool; + /** * @template U *