League URI Interfaces
PHP
Latest commit dcc0be5 Jan 4, 2017 @nyamsprod nyamsprod prepare 1.0.0 release
Permalink
Failed to load latest commit information.
.github
src
.editorconfig
.gitattributes
.gitignore
.php_cs
CHANGELOG.md
CONDUCT.md
LICENSE
README.md
composer.json

README.md

Uri Interfaces

This package contains an interface to represents URI objects according to RFC 3986.

System Requirements

You need:

  • PHP >= 5.3.0 but the latest stable version of PHP is recommended

Install

$ composer require league/uri-interfaces

Documentation

League\Uri\Interfaces\Uri

The Uri interface models generic URIs as specified in RFC 3986. The interface provides methods for interacting with the various URI parts, which will obviate the need for repeated parsing of the URI. It also specifies a __toString() method for casting the modeled URI to its string representation.

Accessing URI properties

The Uri interface defines the following methods to access the URI string representation, its individual parts and components.

<?php

public Uri::__toString(): string
public Uri::getScheme(void): string
public Uri::getUserInfo(void): string
public Uri::getHost(void): string
public Uri::getPort(void): int|null
public Uri::getAuthority(void): string
public Uri::getPath(void): string
public Uri::getQuery(void): string
public Uri::getFragment(void): string

Modifying URI properties

The Uri interface defines the following modifying methods. these methods must be implemented such that they retain the internal state of the current instance and return an instance that contains the changed state.

Delimiter characters are not part of the URI component and must not be added to the modifying method submitted value. If present they will be treated as part of the URI component content.

These methods will trigger a InvalidArgumentException exception if the resulting URI is not valid. The validation is scheme dependent.

<?php

public Uri::withScheme(string $scheme): self
public Uri::withUserInfo(string $user [, string $password = null]): self
public Uri::withHost(string $host): self
public Uri::withPort(int|null $port): self
public Uri::withPath(string $path): self
public Uri::withQuery(string $query): self
public Uri::withFragment(string $fragment): self

Relation with PSR-7

This interface exposes the same methods as Psr\Http\Message\UriInterface. But, unlike the UriInterface, this interface does not require the http and https schemes to be supported. The supported schemes are determined by the each concrete implementation.

Contributing

Contributions are welcome and will be fully credited. Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email nyamsprod@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.