@@ -26,15 +26,17 @@ final class Dsn
26
26
private $ password ;
27
27
private $ port ;
28
28
private $ options ;
29
+ private $ path ;
29
30
30
- public function __construct (string $ scheme , string $ host , ?string $ user = null , ?string $ password = null , ?int $ port = null , array $ options = [])
31
+ public function __construct (string $ scheme , string $ host , ?string $ user = null , ?string $ password = null , ?int $ port = null , array $ options = [], ? string $ path = null )
31
32
{
32
33
$ this ->scheme = $ scheme ;
33
34
$ this ->host = $ host ;
34
35
$ this ->user = $ user ;
35
36
$ this ->password = $ password ;
36
37
$ this ->port = $ port ;
37
38
$ this ->options = $ options ;
39
+ $ this ->path = $ path ;
38
40
}
39
41
40
42
public static function fromString (string $ dsn ): self
@@ -54,9 +56,10 @@ public static function fromString(string $dsn): self
54
56
$ user = isset ($ parsedDsn ['user ' ]) ? urldecode ($ parsedDsn ['user ' ]) : null ;
55
57
$ password = isset ($ parsedDsn ['pass ' ]) ? urldecode ($ parsedDsn ['pass ' ]) : null ;
56
58
$ port = $ parsedDsn ['port ' ] ?? null ;
59
+ $ path = $ parsedDsn ['path ' ] ?? null ;
57
60
parse_str ($ parsedDsn ['query ' ] ?? '' , $ query );
58
61
59
- return new self ($ parsedDsn ['scheme ' ], $ parsedDsn ['host ' ], $ user , $ password , $ port , $ query );
62
+ return new self ($ parsedDsn ['scheme ' ], $ parsedDsn ['host ' ], $ user , $ password , $ port , $ query, $ path );
60
63
}
61
64
62
65
public function getScheme (): string
@@ -88,4 +91,9 @@ public function getOption(string $key, $default = null)
88
91
{
89
92
return $ this ->options [$ key ] ?? $ default ;
90
93
}
94
+
95
+ public function getPath (): ?string
96
+ {
97
+ return $ this ->path ;
98
+ }
91
99
}
0 commit comments