Skip to content

Commit 1a30cdc

Browse files
committed
Add getter "getDbName" on the Database class
1 parent bf16b71 commit 1a30cdc

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/Database.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* You can obtain one at https://mozilla.org/MPL/2.0/.
1818
* @license MPL-2.0 https://mozilla.org/MPL/2.0/
1919
* @source https://github.com/wdes/simple-php-model-system
20-
* @version 1.2.0
20+
* @version 1.2.1
2121
*/
2222

2323
/**
@@ -154,6 +154,14 @@ public function getConnection(): PDO
154154
return $this->connection;
155155
}
156156

157+
/**
158+
* @since 1.2.1
159+
*/
160+
public function getDbName(): string
161+
{
162+
return $this->dbConfig['name'];
163+
}
164+
157165
/**
158166
* Access the database instance
159167
*

tests/DatabaseTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace SimplePhpModelSystem\Test\Models;
6+
7+
use SimplePhpModelSystem\Database;
8+
use SimplePhpModelSystem\Tests\DatabaseAbstractTestCase;
9+
10+
class DatabaseTest extends DatabaseAbstractTestCase
11+
{
12+
13+
public function testGetDbName(): void
14+
{
15+
$this->assertNotEmpty(Database::getInstance()->getDbName());
16+
}
17+
18+
}

0 commit comments

Comments
 (0)