Skip to content

Commit

Permalink
add hasDriver method
Browse files Browse the repository at this point in the history
  • Loading branch information
transistive committed Sep 20, 2023
1 parent 4390103 commit d8f8893
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Basic/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions src/Common/DriverSetupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResultFormat>
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Contracts/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit d8f8893

Please sign in to comment.