[Notifier] Added possibility to extract path from provided DSN
This commit is contained in:
parent
e0f6cdb1c7
commit
ab9b49b5c6
@ -26,8 +26,9 @@ final class Dsn
|
|||||||
private $password;
|
private $password;
|
||||||
private $port;
|
private $port;
|
||||||
private $options;
|
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->scheme = $scheme;
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
@ -35,6 +36,7 @@ final class Dsn
|
|||||||
$this->password = $password;
|
$this->password = $password;
|
||||||
$this->port = $port;
|
$this->port = $port;
|
||||||
$this->options = $options;
|
$this->options = $options;
|
||||||
|
$this->path = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fromString(string $dsn): self
|
public static function fromString(string $dsn): self
|
||||||
@ -54,9 +56,10 @@ final class Dsn
|
|||||||
$user = isset($parsedDsn['user']) ? urldecode($parsedDsn['user']) : null;
|
$user = isset($parsedDsn['user']) ? urldecode($parsedDsn['user']) : null;
|
||||||
$password = isset($parsedDsn['pass']) ? urldecode($parsedDsn['pass']) : null;
|
$password = isset($parsedDsn['pass']) ? urldecode($parsedDsn['pass']) : null;
|
||||||
$port = $parsedDsn['port'] ?? null;
|
$port = $parsedDsn['port'] ?? null;
|
||||||
|
$path = $parsedDsn['path'] ?? null;
|
||||||
parse_str($parsedDsn['query'] ?? '', $query);
|
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
|
public function getScheme(): string
|
||||||
@ -88,4 +91,9 @@ final class Dsn
|
|||||||
{
|
{
|
||||||
return $this->options[$key] ?? $default;
|
return $this->options[$key] ?? $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPath(): ?string
|
||||||
|
{
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user