Documentation

Dsn
in package

Data Source Name (DSN), a reference to a path on a local or remote system with the ability to add parameters.

The format for the DSN is inspired by the PDO DSN format (https://www.php.net/manual/en/ref.pdo-mysql.connection.php) where you have a string containing Semicolon Separated Values (SSV), where each part is a key=value pair. Exception to this rule is the first entry in the string; this is the URI where the referenced Data Source is located.

A simple example can be a reference to your project folder:

file:///home/mvriel/project/src

Yet a more complex example may be a reference to a specific branch on a git repository:

git+https://github.com/phpDocumentor/phpDocumentor;path=/src;branch=release/3.0

In the example above we reference a git repository using the http protocol and as options we mention that the branch that we would like to parse is release/3.0 and in it we want to start at the path /src.

Table of Contents

$dsn  : string
$parameters  : array<string|int, string>
$uri  : UriInterface
__construct()  : mixed
Initializes the Dsn
__toString()  : string
Returns a string representation of the DSN.
createFromString()  : self
createFromUri()  : self
getHost()  : string
Returns the host part of the DSN
getParameters()  : array<string|int, string>
Returns the parameters part of the DSN
getPassword()  : string
Returns the password part of the DSN
getPath()  : Path
Returns the path part of the DSN
getPort()  : int|null
Returns the port part of the DSN
getQuery()  : array<string|int, string>
Returns the query part of the DSN
getScheme()  : string|null
Returns the scheme part of the DSN
getUsername()  : string
Returns the username part of the DSN
isWindowsLocalPath()  : bool
resolve()  : self
withPath()  : self
parseParameter()  : Generator<string, string>
parseParameters()  : array<string, string>
validates and sets the parameters property

Properties

$dsn

private string $dsn

$parameters

private array<string|int, string> $parameters

Methods

__construct()

Initializes the Dsn

public __construct(UriInterface $uri, array<string|int, string> $parameters, string $dsn) : mixed
Parameters
$uri : UriInterface
$parameters : array<string|int, string>
$dsn : string
Return values
mixed

__toString()

Returns a string representation of the DSN.

public __toString() : string
Return values
string

createFromString()

public static createFromString(string $dsn) : self
Parameters
$dsn : string
Return values
self

createFromUri()

public static createFromUri(UriInterface $uri[, array<string|int, string> $parameters = [] ]) : self
Parameters
$uri : UriInterface
$parameters : array<string|int, string> = []
Return values
self

getHost()

Returns the host part of the DSN

public getHost() : string
Return values
string

getParameters()

Returns the parameters part of the DSN

public getParameters() : array<string|int, string>
Return values
array<string|int, string>

getPassword()

Returns the password part of the DSN

public getPassword() : string
Return values
string

getPath()

Returns the path part of the DSN

public getPath() : Path
Return values
Path

getPort()

Returns the port part of the DSN

public getPort() : int|null
Return values
int|null

getQuery()

Returns the query part of the DSN

public getQuery() : array<string|int, string>
Return values
array<string|int, string>

getScheme()

Returns the scheme part of the DSN

public getScheme() : string|null
Return values
string|null

getUsername()

Returns the username part of the DSN

public getUsername() : string
Return values
string

isWindowsLocalPath()

public isWindowsLocalPath() : bool
Return values
bool

resolve()

public resolve(Dsn $baseDsn) : self
Parameters
$baseDsn : Dsn
Return values
self

withPath()

public withPath(Path $path) : self
Parameters
$path : Path
Return values
self

parseParameter()

private static parseParameter(string $part) : Generator<string, string>
Parameters
$part : string
Return values
Generator<string, string>

parseParameters()

validates and sets the parameters property

private static parseParameters(array<string|int, string> $parameters) : array<string, string>
Parameters
$parameters : array<string|int, string>
Return values
array<string, string>

Search results