API / Minn\Http / IriParts

IriParts final readonly class

Minn\Http\IriParts · public/minn/src/Minn/Http/IriParts.php · 138 lines

An IRI (a URL that may carry non-ASCII text) split into its parts and written back normalized: scheme and host in lower case, a scheme's default port dropped, dot segments removed, and every character a URL may not hold percent-encoded. The IRI form keeps non-ASCII characters; the URI form encodes them too.

Uses 1

Constants and properties

privatePORTS = array ( 'acap' => 674, 'dict' => 2628, 'file' => NULL, 'http' => 80, 'https' => 443, )
propreadonly ?string $scheme

Promoted from the constructor.

propreadonly ?string $userinfo

Promoted from the constructor.

propreadonly ?string $host

Promoted from the constructor.

propreadonly ?int $port

Promoted from the constructor.

propreadonly string $path

Promoted from the constructor.

propreadonly ?string $query

Promoted from the constructor.

propreadonly ?string $fragment

Promoted from the constructor.

Public

new__construct(?string $scheme, ?string $userinfo, ?string $host, ?int $port, string $path, ?string $query, ?string $fragment)#
staticparse(string $iri): self#

The parts of an IRI (RFC 3986 appendix B).

methodvalid(): bool#

Whether the parts make a well-formed IRI: a valid scheme when there is one, no "//" path without an authority.

methodresolve(self $ref): ?self#

The reference resolved against this base (RFC 3986 section 5.2), or null when the base has no scheme.

methodwithHost(?string $host): self#

The same IRI with another host.

methodwithPath(string $path): self#

The same IRI with another path.

methodtoIri(): string#

The normalized IRI: non-ASCII characters stay as they are.

methodtoUri(): string#

The normalized URI: non-ASCII characters percent-encoded too.

Internals 4

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatewrite(string $keep): string#

The text, with $keep naming the extra byte ranges left unencoded.

privatemergePath(string $path): string#
privateremoveDots(string $path): string#
privateencode(string $text, string $allowed, string $keep): string#