Nexus API Reference

Host
in package
implements Stringable

Read onlyYes
FinalYes
Tags
psalm-api

Immutable host value object. Accepts IPv4 literals, IPv6 literals, and RFC 1123 hostnames. IPv6 bracket form ([::1]) is documented out of scope for v1.

RFC 1123 hostname rules: total length 1–253 chars; labels 1–63 chars; alphanumeric and interior hyphens only; no leading or trailing hyphen per label; underscores are disallowed.

example

$host = Host::of('10.0.0.1'); echo $host; // '10.0.0.1' $host->isIp(); // true $host->isIpv6(); // false

$host6 = Host::of('::1'); $host6->isIp(); // true $host6->isIpv6(); // true

$hostname = Host::of('example.com'); $hostname->isIp(); // false

Table of Contents

Interfaces

Stringable

Properties

$value  : string

Methods

__toString()  : string
equals()  : bool
isIp()  : bool
Returns true when the value is an IPv4 or IPv6 literal.
isIpv6()  : bool
Returns true only when the value is an IPv6 literal.
isLoopback()  : bool
Returns true when the host refers to the local machine only: the IPv4 loopback range 127.0.0.0/8, the IPv6 loopback `::1`, or the `localhost` hostname. Used to distinguish a development bind from a network-exposed one. Note `0.0.0.0` / `::` (all-interfaces) are NOT loopback — they expose the port on every interface.
of()  : self
Create a Host from a string value.

Properties

$value

public string $value

Methods

__toString()

public __toString() : string
Attributes
#[Override]
Return values
string

equals()

public equals(self $other) : bool
Parameters
$other : self
Return values
bool

isIp()

Returns true when the value is an IPv4 or IPv6 literal.

public isIp() : bool
Return values
bool

isIpv6()

Returns true only when the value is an IPv6 literal.

public isIpv6() : bool
Return values
bool

isLoopback()

Returns true when the host refers to the local machine only: the IPv4 loopback range 127.0.0.0/8, the IPv6 loopback `::1`, or the `localhost` hostname. Used to distinguish a development bind from a network-exposed one. Note `0.0.0.0` / `::` (all-interfaces) are NOT loopback — they expose the port on every interface.

public isLoopback() : bool
Return values
bool

of()

Create a Host from a string value.

public static of(string $value) : self

Accepts IPv4 literals, IPv6 literals, and RFC 1123 hostnames.

Parameters
$value : string
Tags
throws
InvalidArgumentException

when the value is empty or not a valid host.

Return values
self
On this page

Search results