14
14
final class Dsn extends AbstractDsn
15
15
{
16
16
/**
17
- * @psalm-param string[] $options
17
+ * @psalm-param array< string,string> $options
18
18
*/
19
19
public function __construct (
20
- private string $ driver ,
21
- private string $ host ,
22
- private string |null $ databaseName = null ,
23
- private string $ port = '1521 ' ,
24
- private array $ options = []
20
+ string $ driver = ' oci ' ,
21
+ string $ host = ' 127.0.0.1 ' ,
22
+ string |null $ databaseName = null ,
23
+ string $ port = '1521 ' ,
24
+ array $ options = []
25
25
) {
26
26
parent ::__construct ($ driver , $ host , $ databaseName , $ port , $ options );
27
27
}
@@ -43,20 +43,20 @@ public function __construct(
43
43
*/
44
44
public function asString (): string
45
45
{
46
- if (! empty ( $ this ->databaseName )) {
47
- $ dsn = " $ this ->driver : " . " dbname= $ this -> host : $ this -> port / $ this -> databaseName " ;
48
- } else {
49
- $ dsn = " $ this ->driver : " . " dbname= $ this -> host : $ this -> port " ;
50
- }
46
+ $ driver = $ this ->getDriver ();
47
+ $ host = $ this ->getHost () ;
48
+ $ databaseName = $ this -> getDatabaseName ();
49
+ $ port = $ this ->getPort () ;
50
+ $ options = $ this -> getOptions ();
51
51
52
- $ parts = [] ;
52
+ $ dsn = " $ driver :dbname= $ host : $ port " ;
53
53
54
- foreach ( $ this -> options as $ key => $ value ) {
55
- $ parts [] = "$ key = $ value " ;
54
+ if (! empty ( $ databaseName ) ) {
55
+ $ dsn . = "/ $ databaseName " ;
56
56
}
57
57
58
- if (! empty ( $ parts ) ) {
59
- $ dsn .= ' ; ' . implode ( ' ; ' , $ parts ) ;
58
+ foreach ( $ options as $ key => $ value ) {
59
+ $ dsn .= " ; $ key = $ value " ;
60
60
}
61
61
62
62
return $ dsn ;
0 commit comments