innmind / ip
IP addresses model
Installs: 110 268
Dependents: 5
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
pkg:composer/innmind/ip
Requires
- php: ~8.4
- innmind/immutable: ~6.0
Requires (Dev)
- innmind/black-box: ~6.5
- innmind/coding-standard: ~2.0
- innmind/static-analysis: ~1.3
This package is auto-updated.
Last update: 2026-01-19 11:28:24 UTC
README
Immutable IP value objects.
Installation
require innmind/ip
Usage
use Innmind\IP\{ IP, IPv4, IPv6, }; use Innmind\Immutable\{ Maybe, Attempt, }; $ipv4 = IP::v4('192.168.0.1'); $ipv6 = IP::v6('2001:db8:a0b:12f0::1'); IPv4::of('192.168.0.1'); // same as above IPv6::of('2001:db8:a0b:12f0::1'); // same as above IPv4::of('localhost'); // throws DomainException IPv6::of('localhost'); // throws DomainException IPv4::maybe('localhost'); // returns Maybe<IPv4> IPv6::maybe('localhost'); // returns Maybe<IPv6> IPv4::attempt('localhost'); // returns Attempt<IPv4> IPv6::attempt('localhost'); // returns Attempt<IPv6>