承接 decodelabs/compass 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

decodelabs/compass

最新稳定版本:v0.4.4

Composer 安装命令:

composer require decodelabs/compass

包简介

Parse, inspect and test IP addresses

关键字:

README 文档

README

PHP from Packagist Latest Version Total Downloads GitHub Workflow Status PHPStan License

Parse, inspect and test IP addresses

Compass provides an accurate disassembly of both v4 and v6 IP addresses and the means to inspect and compare them.

Installation

This package requires PHP 8.4 or higher.

Install via Composer:

composer require decodelabs/compass

Usage

Parse IP strings, integers and binaries and inspect them:

use DecodeLabs\Compass\Ip;

$ip = Ip::parse('127.0.0.1');

if($ip->isV4()) {
    // Do something
}

if($ip->isLoopback()) {
    // Do something else
}

$v6Hybrid = $ip->toV6(); // ::ffff:127.0.0.1

$v6 = Ip::parse('fe80:0:0:0:202:b3ff:fe1e:8329');

if($ip->isV6()) {
    // The future
}

Check to see if an IP is within a range:

if($ip->isIn('127.0.0.0/8')) {} // CIDR
if($ip->isIn('127.0.0.0/255.0.0.0')) {} // Netmask
if($ip->isIn('127.0.0.4-127.0.0.10')) {} // Range
if($ip->isIn('127.0.0.4+6')) {} // Relative range
if($ip->isIn('127.0.0.*')) {} // Wildcards

if($v6->isIn('fe80:0:0:0:202:b3ff:fe1e:0/128')) {} // CIDR
if($v6->isIn('fe80:0:0:0:202:b3ff:fe1e:0-fe80:0:0:0:202:b3ff:fe1e:ffff')) {} // Range
if($v6->isIn('fe80:0:0:0:202:b3ff:fe1e:0+9999')) {} // Relative range
if($v6->isIn('fe80:0:0:0:202:b3ff:fe1e:*')) {} // Wildcards

Licensing

Compass is licensed under the MIT License. See LICENSE for the full license text.

统计信息

  • 总下载量: 4.24k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 4
  • 推荐数: 1

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-09