From 1a30cdccae71730001f58e05e12bbed1358168aa Mon Sep 17 00:00:00 2001 From: William Desportes Date: Tue, 10 May 2022 16:07:14 +0200 Subject: [PATCH] Add getter "getDbName" on the Database class --- src/Database.php | 10 +++++++++- tests/DatabaseTest.php | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/DatabaseTest.php diff --git a/src/Database.php b/src/Database.php index d3b1d2c..e45cc4d 100644 --- a/src/Database.php +++ b/src/Database.php @@ -17,7 +17,7 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. * @license MPL-2.0 https://mozilla.org/MPL/2.0/ * @source https://github.com/wdes/simple-php-model-system - * @version 1.2.0 + * @version 1.2.1 */ /** @@ -154,6 +154,14 @@ public function getConnection(): PDO return $this->connection; } + /** + * @since 1.2.1 + */ + public function getDbName(): string + { + return $this->dbConfig['name']; + } + /** * Access the database instance * diff --git a/tests/DatabaseTest.php b/tests/DatabaseTest.php new file mode 100644 index 0000000..813b039 --- /dev/null +++ b/tests/DatabaseTest.php @@ -0,0 +1,18 @@ +assertNotEmpty(Database::getInstance()->getDbName()); + } + +}