PHP Класс GuzzleHttp\Psr7\UriNormalizer

Автор: Tobias Schultze
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
isEquivalent ( Psr\Http\Message\UriInterface $uri1, Psr\Http\Message\UriInterface $uri2, integer $normalizations = self::PRESERVING_NORMALIZATIONS ) : boolean Whether two URIs can be considered equivalent.
normalize ( Psr\Http\Message\UriInterface $uri, integer $flags = self::PRESERVING_NORMALIZATIONS ) : Psr\Http\Message\UriInterface Returns a normalized URI.

Приватные методы

Метод Описание
__construct ( )
capitalizePercentEncoding ( Psr\Http\Message\UriInterface $uri )
decodeUnreservedCharacters ( Psr\Http\Message\UriInterface $uri )

Описание методов

isEquivalent() публичный статический Метод

Both URIs are normalized automatically before comparison with the given $normalizations bitmask. The method also accepts relative URI references and returns true when they are equivalent. This of course assumes they will be resolved against the same base URI. If this is not the case, determination of equivalence or difference of relative references does not mean anything.
public static isEquivalent ( Psr\Http\Message\UriInterface $uri1, Psr\Http\Message\UriInterface $uri2, integer $normalizations = self::PRESERVING_NORMALIZATIONS ) : boolean
$uri1 Psr\Http\Message\UriInterface An URI to compare
$uri2 Psr\Http\Message\UriInterface An URI to compare
$normalizations integer A bitmask of normalizations to apply, see constants
Результат boolean

normalize() публичный статический Метод

The scheme and host component are already normalized to lowercase per PSR-7 UriInterface. This methods adds additional normalizations that can be configured with the $flags parameter. PSR-7 UriInterface cannot distinguish between an empty component and a missing component as getQuery(), getFragment() etc. always return a string. This means the URIs "/?#" and "/" are treated equivalent which is not necessarily true according to RFC 3986. But that difference is highly uncommon in reality. So this potential normalization is implied in PSR-7 as well.
public static normalize ( Psr\Http\Message\UriInterface $uri, integer $flags = self::PRESERVING_NORMALIZATIONS ) : Psr\Http\Message\UriInterface
$uri Psr\Http\Message\UriInterface The URI to normalize
$flags integer A bitmask of normalizations to apply, see constants
Результат Psr\Http\Message\UriInterface The normalized URI