Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
added databaseprovider interface
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy-j committed Apr 16, 2019
1 parent 66717dc commit 03ecaa0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/DatabaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
*
* echo $manager->database('runtime')->select()->from('users')->count();
*/
final class DatabaseManager implements SingletonInterface, InjectorInterface
final class DatabaseManager implements DatabaseProviderInterface, SingletonInterface, InjectorInterface
{
/** @var DatabaseConfig */
private $config = null;
Expand Down Expand Up @@ -129,11 +129,11 @@ public function getDatabases(): array
* Get Database associated with a given database alias or automatically created one.
*
* @param string|null $database
* @return Database
* @return Database|DatabaseInterface
*
* @throws DBALException
*/
public function database(string $database = null): Database
public function database(string $database = null): DatabaseInterface
{
if (empty($database)) {
$database = $this->config->getDefaultDatabase();
Expand Down
24 changes: 24 additions & 0 deletions src/DatabaseProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php declare(strict_types=1);
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

namespace Spiral\Database;

use Spiral\Database\Exception\DBALException;

interface DatabaseProviderInterface
{
/**
* Get Database associated with a given database alias or automatically created one.
*
* @param string|null $database
* @return DatabaseInterface
*
* @throws DBALException
*/
public function database(string $database = null): DatabaseInterface;
}

0 comments on commit 03ecaa0

Please sign in to comment.