Skip to content

Commit badbb1d

Browse files
committed
add hasDriver method
1 parent 9c98213 commit badbb1d

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

src/Basic/Client.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public function getDriver(?string $alias): DriverInterface
5858
return $this->client->getDriver($alias);
5959
}
6060

61+
public function hasDriver(string $alias): bool
62+
{
63+
return $this->client->hasDriver($alias);
64+
}
65+
6166
public function writeTransaction(callable $tsxHandler, ?string $alias = null, ?TransactionConfiguration $config = null)
6267
{
6368
return $this->client->writeTransaction($tsxHandler, $alias, $config);

src/Client.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ public function verifyConnectivity(?string $driver = null): bool
153153
return $this->driverSetups->verifyConnectivity($this->defaultSessionConfiguration, $driver);
154154
}
155155

156+
public function hasDriver(string $alias): bool
157+
{
158+
return $this->driverSetups->hasDriver($alias);
159+
}
160+
156161
public function bindTransaction(?string $alias = null, ?TransactionConfiguration $config = null): void
157162
{
158163
$alias ??= $this->driverSetups->getDefaultAlias();

src/Common/DriverSetupManager.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public function withSetup(DriverSetup $setup, ?string $alias = null, ?int $prior
7777
return $tbr;
7878
}
7979

80+
public function hasDriver(string $alias): bool
81+
{
82+
return array_key_exists($alias, $this->driverSetups);
83+
}
84+
8085
/**
8186
* @return DriverInterface<ResultFormat>
8287
*/

src/Contracts/ClientInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public function beginTransaction(?iterable $statements = null, ?string $alias =
7676
*/
7777
public function getDriver(?string $alias): DriverInterface;
7878

79+
/**
80+
* Checks to see if the Client has the driver registered with the provided alias.
81+
*/
82+
public function hasDriver(string $alias): bool;
83+
7984
/**
8085
* @template U
8186
*

0 commit comments

Comments
 (0)