From ab9b49b5c6f971e1b4c2e694b0ca3d3a829d6eae Mon Sep 17 00:00:00 2001 From: Dmitry Pigin Date: Sun, 1 Dec 2019 21:03:44 +0200 Subject: [PATCH] [Notifier] Added possibility to extract path from provided DSN --- src/Symfony/Component/Notifier/Transport/Dsn.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Transport/Dsn.php b/src/Symfony/Component/Notifier/Transport/Dsn.php index a69bf0a1b7..447019fef8 100644 --- a/src/Symfony/Component/Notifier/Transport/Dsn.php +++ b/src/Symfony/Component/Notifier/Transport/Dsn.php @@ -26,8 +26,9 @@ final class Dsn private $password; private $port; private $options; + private $path; - public function __construct(string $scheme, string $host, ?string $user = null, ?string $password = null, ?int $port = null, array $options = []) + public function __construct(string $scheme, string $host, ?string $user = null, ?string $password = null, ?int $port = null, array $options = [], ?string $path = null) { $this->scheme = $scheme; $this->host = $host; @@ -35,6 +36,7 @@ final class Dsn $this->password = $password; $this->port = $port; $this->options = $options; + $this->path = $path; } public static function fromString(string $dsn): self @@ -54,9 +56,10 @@ final class Dsn $user = isset($parsedDsn['user']) ? urldecode($parsedDsn['user']) : null; $password = isset($parsedDsn['pass']) ? urldecode($parsedDsn['pass']) : null; $port = $parsedDsn['port'] ?? null; + $path = $parsedDsn['path'] ?? null; parse_str($parsedDsn['query'] ?? '', $query); - return new self($parsedDsn['scheme'], $parsedDsn['host'], $user, $password, $port, $query); + return new self($parsedDsn['scheme'], $parsedDsn['host'], $user, $password, $port, $query, $path); } public function getScheme(): string @@ -88,4 +91,9 @@ final class Dsn { return $this->options[$key] ?? $default; } + + public function getPath(): ?string + { + return $this->path; + } }