|Classes of Caleb||>||Aggregator||>||README.md||>||Download|
A stand-alone class implementation of the IPv4+IPv6 IP+CIDR aggregator from CIDRAM.
How to install:
As a stand-alone PHP class, installing it is exceptionally easy. You can download the file containing the class,
Note: The code in this class is based upon code in the CIDRAM package, but the two are NOT dependent on each other.
After you've downloaded the file, to allow your projects to use the class, PSR-4 autoloading is preferred (particularly if you're using a large number of different, unrelated classes). If you're installing the class via Composer, then this will already be taken care of for you, and you won't need to worry about it. Alternatively, if you're installing it manually (or without Composer), and don't want to use a PSR-4 autoloader, you can simply require or include the class into your projects (which may be much easier in many cases) by including the respective statement to point to the class file in the relevant PHP files:
How to use:
The simplest way to use Aggregator is to create a new instance of the class and enter some data to be aggregated as a parameter to the aggregate method. The aggregate method will return an aggregate of the entered data.
In the case of the above example, if this is entered as
Data is newline-delimited and each line represents one item to be aggregated. Aggregator handles IPv4+IPv6 seamlessly, attempts to clean up each item (i.e., remove invalid and superfluous data in order to reduce to a valid IP or CIDR), attempts to aggregate the resultant cleaned up data (unreadable and invalid data is rejected), and then returns the resultant aggregated data.
It is possible to obtain more information about each aggregation operation if desired. If "Results" is set to
Generally, it is better to create a new class instance for each aggregation operation. However, if you want to recycle an old instance, and want to continue to retrieve these values after each operation, you can reset these values to their initial state between operations by using the "resetNumbers" method:
Regardless of whether "Results" is
Additionally, "ExpandIPv4" and "ExpandIPv6" public methods are provided with the class, and they function in exactly the same way their CIDRAM package closure counterparts. Calling either of these with an IPv4 or IPv6 IP address respectively will return an array containing the potential factors for the given IP address. The potential factors are all possible subnets (or CIDRs) that the given IP address is a member of. When a valid IP address is supplied, "ExpandIPv4" and "ExpandIPv6" and should return an array with 32 and 128 elements respectively.
Licensed as GNU General Public License version 2.0 (GPLv2).
Please use the issues page of this repository.
Last modified: 22 September 2017 (2017.09.22).