Skip to content

kester36/ip-list-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IP Collection

This is IP collection library. You can fill collection IP's in several formats: from single IP to range of IPs.

Then you can check is any IP is included inside this collection.

How to use

Create and fill collection

use Kester36\IpCollection\IpCollection;
use Kester36\IpCollection\Ip;
use Kester36\IpCollection\IpRange;
use Kester36\IpCollection\IpCidr;

$collection = new IpCollection;

// add single IP
$collection->add(new Ip('10.10.0.1'));
$collection->add(new Ip('10.10.100.212'));
// add IPv4 range
$collection->add(new IpRange('127.0.0.1-127.0.0.100'));
$collection->add(new IpRange('127.0.1.223-127.0.2.31'));
// add CIDR notation (IPv4)
$collection->add(new IpCidr('192.168.0.0/16'));

Check if IP in collection

/** @var Kester36\IpCollection\IpCollection $collection */
$collection->includes('192.168.100.200');

Get all items from collection

/** @var Kester36\IpCollection\IpCollection $collection */
$items = $collection->getAll();

About

Set IPs list and check any IP is it in the list

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages