cmdrsharp / ip-addressing
A collection of traits for IP Operations.
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:libr
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-10-22 08:14:33 UTC
README
A collection of traits for general IP operations. New traits may be added over time.
Current Requirements
- PHP 7.1 or newer
Installation
Via composer
$ composer require cmdrsharp/ip-addressing
Usage
Use the applicable Trait in your classes.
use CmdrSharp\IpAddressing\IPv4; use CmdrSharp\IpAddressing\Subnet; class RandomClass { use IPv4, Subnet; protected function randomFunction() { $result = $this->getNetworkFromIp('192.168.0.55', '255.255.255.0'); // 192.168.0.0 $result = $this->getBroadcastFromIp('192.168.0.55', '255.255.255.0'); // 192.168.0.255 $result = $this->getCidrFromNetmask('255.255.255.0'); // 24 } }
What trait contains what?
IPv4
getNetworkFromIp(string $ip, string $netmask): string
getBroadcastFromIp(string $ip, string $netmask): string
Subnet
getCidrFromNetmask(string $netmask): string
Versioning
This package follows Explicit Versioning.