# Class HttpSoft\Uri\UriData

Abstraction for convenient management of URI components, used within HttpSoft\Uri\Uri and HttpSoft\Uri\UriNormalizer.

Source code on GitHub.

use HttpSoft\Uri\UriData;

$uriData = new UriData();
$uriData->__toString(); // ''
(string) $uriData; // ''
echo $uriData; // ''

$uriData->setScheme('https');
$uriData->getScheme(); // 'https'
(string) $uriData; // 'https:'

$uriData->setHost('example.com');
$uriData->getHost(); // 'example.com'
(string) $uriData; // 'https://example.com'

$uriData->setPath('path/to/action');
$uriData->getPath(); // 'path/to/action'
(string) $uriData; // 'https://example.com/path/to/action'

$uriData->setQuery('query=string');
$uriData->getQuery(); // 'query=string'
(string) $uriData; // 'https://example.com/path/to/action?query=string'

$uriData->setFragment('fragment');
$uriData->getFragment(); // 'fragment'
(string) $uriData; // 'https://example.com/path/to/action?query=string#fragment'

$uriData->setPort(8080);
$uriData->getPort(); // 8080
(string) $uriData; 'https://example.com:8080/path/to/action?query=string#fragment'
// If the port is standard (80 for http connection or 443 for https connection), it will be omitted.
$uriData->setPort(443);
$uriData->getPort(); // null
(string) $uriData; 'https://example.com/path/to/action?query=string#fragment'

$uriData->setUserInfo('user', 'pass');
$uriData->getUserInfo(); // 'user:pass'
$uriData->getAuthority(); // 'user:pass@example.com:8080'
(string) $uriData; // 'https://user:pass@example.com:8080/path/to/action?query=string#fragment'

# Public methods

# __toString

Returns a string representation of the URI ('https://example.com/path', '/path', '').

public function __toString(): string;

# getScheme

Gets scheme component of the URI ('http', 'https', '').

public function getScheme(): string;

# setScheme

Sets scheme component to the URI.

public function setScheme(string $scheme): void;

# getUserInfo

Gets user information component of the URI (user:password, user, '').

public function getUserInfo(): string;

# setUserInfo

Sets user information component to the URI.

public function setUserInfo(string $user, ?string $password = null): void;

# getHost

Gets host component of the URI ('example.com', '127.0.0.1', '').

public function getHost(): string;

# setHost

Sets host component to the URI.

public function setHost(string $host): void;

# getPort

Gets port component of the URI (1, 65535, null).

public function getPort(): ?int;

# setPort

Sets port component to the URI.

public function setPort(?int $port): void;

# getPath

Gets path component of the URI ('/path/to', 'path/to', '/', '').

public function getPath(): string;

# setPath

Sets path component to the URI.

public function setPath(string $path): void;

# getQuery

Gets query string component of the URI ('key1=value1&key2=value2', 'key=value', '').

public function getQuery(): string;

# setQuery

Sets query string component to the URI.

public function setQuery(string $query): void;

# getFragment

Gets fragment (hash) component of the URI ('any-string', '').

public function getFragment(): string;

# setFragment

Sets fragment (hash) component to the URI.

public function setFragment(string $fragment): void;

# getAuthority

Gets authority component of the URI ('user:pass@example.com:8080', 'example.com', '').

public function getAuthority(): string;