Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
DatabaseConnection | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getConnectionSetting | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
open | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\Core\Database; |
6 | |
7 | use PeServer\Core\Database\DatabaseContext; |
8 | use PeServer\Core\Log\ILoggerFactory; |
9 | use PeServer\Core\Throws\NotImplementedException; |
10 | |
11 | class DatabaseConnection implements IDatabaseConnection |
12 | { |
13 | /** |
14 | * 生成。 |
15 | * |
16 | * @param ConnectionSetting $setting 接続設定。 |
17 | */ |
18 | public function __construct( |
19 | protected readonly ConnectionSetting $setting, |
20 | protected readonly ILoggerFactory $loggerFactory |
21 | ) { |
22 | } |
23 | |
24 | #region IDatabaseConnection |
25 | |
26 | public function getConnectionSetting(): ConnectionSetting |
27 | { |
28 | return $this->setting; |
29 | } |
30 | |
31 | public function open(): DatabaseContext |
32 | { |
33 | return new DatabaseContext( |
34 | $this->setting, |
35 | $this->loggerFactory->createLogger(DatabaseContext::class) |
36 | ); |
37 | } |
38 | |
39 | #endregion |
40 | } |