@@ -26,15 +26,17 @@ final class Dsn
2626 private $ password ;
2727 private $ port ;
2828 private $ options ;
29+ private $ path ;
2930
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 )
3132 {
3233 $ this ->scheme = $ scheme ;
3334 $ this ->host = $ host ;
3435 $ this ->user = $ user ;
3536 $ this ->password = $ password ;
3637 $ this ->port = $ port ;
3738 $ this ->options = $ options ;
39+ $ this ->path = $ path ;
3840 }
3941
4042 public static function fromString (string $ dsn ): self
@@ -54,9 +56,10 @@ public static function fromString(string $dsn): self
5456 $ user = isset ($ parsedDsn ['user ' ]) ? urldecode ($ parsedDsn ['user ' ]) : null ;
5557 $ password = isset ($ parsedDsn ['pass ' ]) ? urldecode ($ parsedDsn ['pass ' ]) : null ;
5658 $ port = $ parsedDsn ['port ' ] ?? null ;
59+ $ path = $ parsedDsn ['path ' ] ?? null ;
5760 parse_str ($ parsedDsn ['query ' ] ?? '' , $ query );
5861
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 );
6063 }
6164
6265 public function getScheme (): string
@@ -88,4 +91,9 @@ public function getOption(string $key, $default = null)
8891 {
8992 return $ this ->options [$ key ] ?? $ default ;
9093 }
94+
95+ public function getPath (): ?string
96+ {
97+ return $ this ->path ;
98+ }
9199}
0 commit comments