Download the PHP package matracine/ip-tools without Composer
On this page you can find all versions of the php package matracine/ip-tools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ip-tools
IPTOOLS
PHP Library for manipulating network addresses.
This library implements tools for IP network address manipulations. It actualy impelments IPv4 only classes, but IPv6 will come. It has no dependencies others than PHP 7.0.
Classes :
- IPv4\Address
- IPv4\Network
- IPv4\Range
- IPv4\Subnet
Please feal free to open issue for improvements, bugs, requests... IPv6 implementation is on the way.
Docblock documentation implemented.
QA
Service | Result |
---|---|
Travis CI (PHP 7.0 + 7.1 + 7.2) | |
Scrutinizer score | |
Code coverage |
Installation
With composer:
Usage
IPv4\Address
Class for IPv4 Address manipulation.
An IP address is no more than a 32 bits integer. To be more human readable, the dot quad string notation is commonly used (ex : "123.235.123.213").\ Class is immutable : once created cennot be modified. Opérations on an existing instance will return a new instance.
Namespace :
Create an IPv4 Address :
Constructor use integer
Helpers
Retreive value
Operations
Qualify
TODO
- Add string formater
IPv4\Netmask
Class for IPv4 Netmask manipulation.
A Netmask is an IP Address (Netmask extends Address) with only special values allowed (255.255.255.0, 255.0.0.0 etc.). In fact only 33 values are allowed... All Address methods are usable with Netmask, even if certains are meaningless (isRFC1918, getClass...).
Namespace :
Create an IPv4 Netmask :
Constructor use integer
Helpers
Netmask extends Address, so Address helpers are availables. Check are done, Exceptions are thrown when values cannot be used to create valid Netmask.
Retreive value
Use Address methods plus
Operations
Address methods are modified to correspond to the Netmask logic. When shifting a Netmask, we increment or decrement CIDR vaue by the offset.
IPv4\Range
Class for IPv4 Ranges manipulation.
A Range of IP Addresses is consecutives IP addresses, determined by a lower and a upper boundaries. Class is immutable : once created cannot be modified. Opérations on an existing instance will return a new range instance or a fresh Address instance.
Namespace :
Create an IPv4 Range :
Constructor use an lower bound Address and a upper bound Address. Arrange bounds, no need to passer lower bound first
Helpers
Retreive values
Operations
Qualify
IPv4\Subnet
Class for IPv4 Subnets manipulation.
A Subnet is a range (Subnet extends Range) of IP Addresses, determined by a network address and a netmask. Class is immutable : once created cennot be modified. Opérations on an existing instance will return a new subnet instance or a fresh Address instance.
Namespace :
Create an IPv4 Subnet :
Constructor use an Address (network address) and Netmask.
By default, strict network/netmask validity checking is enabled. You can specify third optional parameter (strict) to false to enable intelligent network address calculation, and provide an address within the subnet.
Helpers
Retreive values
Range methods plus :
Operations
Same as Range methods...