innmind / ip
IP地址模型
3.2.0
2023-09-16 16:24 UTC
Requires
- php: ~8.2
- innmind/immutable: ~4.1|~5.0
Requires (Dev)
- innmind/coding-standard: ~2.0
- phpunit/phpunit: ~9.0
- vimeo/psalm: ~5.6
This package is auto-updated.
Last update: 2024-09-16 18:53:28 UTC
README
不可变的IP值对象。
安装
require innmind/ip
用法
use Innmind\IP\{ IP, IPv4, IPv6, Exception\DomainException, }; use Innmind\Immutable\Maybe; $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>