Skip to content

Commit

Permalink
v1.3.1
Browse files Browse the repository at this point in the history
Slightly improved some PHPDoc annotations.
  • Loading branch information
Maikuolan committed Jun 10, 2020
1 parent ffedc6a commit 12f0121
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 21 deletions.
10 changes: 10 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Versioning guidelines for SemVer can be found at: https://semver.org/

=== Changes made since last versioned release ===

(none)

=== Version/Release 1.3.1 ===
PATCH RELEASE.

- [2020.01.11; Bug-fix; Maikuolan]: Syntactically invalid IPv6 addresses could
be potentially accepted or produced by the aggregator in some obscure
circumstances due an insufficiently bound regular expression; Fixed.
Expand All @@ -21,6 +26,11 @@ Versioning guidelines for SemVer can be found at: https://semver.org/
the aggregate method (whether the passed parameter is a string or an array is
now checked by stripInvalidCharactersAndSort, instead of it being assumed).

- [2020.06.11; Maikuolan]: Slightly improved some PHPDoc annotations.

Caleb M (Maikuolan),
June 11, 2020.

=== Version/Release 1.3.0 ===
MINOR RELEASE.

Expand Down
86 changes: 65 additions & 21 deletions src/Aggregator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Aggregator v1.3.1 (last modified: 2020.02.08).
* Aggregator v1.3.1 (last modified: 2020.06.11).
*
* Description: A stand-alone class implementation of the IPv4+IPv6 IP+CIDR
* aggregator from CIDRAM.
Expand All @@ -20,46 +20,74 @@

class Aggregator
{
/** Output. */
/**
* @var string Output.
*/
public $Output = '';

/** Results switch. */
/**
* @var bool Results switch.
*/
public $Results = false;

/** Number of lines for aggregation entered. */
/**
* @var int Number of lines for aggregation entered.
*/
public $NumberEntered = 0;

/** Number of lines for aggregation rejected. */
/**
* @var int Number of lines for aggregation rejected.
*/
public $NumberRejected = 0;

/** Number of lines for aggregation accepted. */
/**
* @var int Number of lines for aggregation accepted.
*/
public $NumberAccepted = 0;

/** Number of lines aggregated or merged. */
/**
* @var int Number of lines aggregated or merged.
*/
public $NumberMerged = 0;

/** Number of lines returned. */
/**
* @var int Number of lines returned.
*/
public $NumberReturned = 0;

/** Time consumed while aggregating data. */
/**
* @var int Time consumed while aggregating data.
*/
public $ProcessingTime = 0;

/** Conversion tables for netmasks to IPv4. */
/**
* @var array Conversion tables for netmasks to IPv4.
*/
private $TableNetmaskIPv4 = [];

/** Conversion tables for netmasks to IPv6. */
/**
* @var array Conversion tables for netmasks to IPv6.
*/
private $TableNetmaskIPv6 = [];

/** Conversion tables for IPv4 to netmasks. */
/**
* @var array Conversion tables for IPv4 to netmasks.
*/
private $TableIPv4Netmask = [];

/** Conversion tables for IPv6 to netmasks. */
/**
* @var array Conversion tables for IPv6 to netmasks.
*/
private $TableIPv6Netmask = [];

/** Specifies the format to use for Aggregator output. 0 = CIDR notation [default]. 1 = Netmask notation. */
/**
* @var int Specifies the format to use for Aggregator output. 0 = CIDR notation [default]. 1 = Netmask notation.
*/
private $Mode = 0;

/** Optional callback. */
/**
* @var array Optional callbacks.
*/
public $callbacks = [];

public function __construct($Mode = 0)
Expand Down Expand Up @@ -230,8 +258,8 @@ public function ExpandIPv6($Addr, $ValidateOnly = false, $FactorLimit = 128)
* Aggregate it!
*
* @param string|array $In The IPs/CIDRs/netmasks to be aggregated. Should
* either be a string, with entries separated by lines, or be an array, an
* entry to each element.
* either be a string, with entries separated by lines, or an
* array with an entry to each element.
* @return string The aggregated data.
*/
public function aggregate($In)
Expand All @@ -248,7 +276,11 @@ public function aggregate($In)
return $this->Output;
}

/** Strips invalid characters from lines and sorts entries. */
/**
* Strips invalid characters from lines and sorts entries.
*
* @param string|array
*/
private function stripInvalidCharactersAndSort(&$In)
{
if (!is_array($In)) {
Expand Down Expand Up @@ -338,7 +370,11 @@ private function stripInvalidCharactersAndSort(&$In)
$In = implode("\n", $In);
}

/** Strips invalid ranges and subordinates. */
/**
* Strips invalid ranges and subordinates.
*
* @param string
*/
private function stripInvalidRangesAndSubs(&$In)
{
if (isset($this->callbacks['newParse']) && is_callable($this->callbacks['newParse'])) {
Expand Down Expand Up @@ -428,7 +464,11 @@ private function stripInvalidRangesAndSubs(&$In)
}
}

/** Merges ranges. */
/**
* Merges ranges.
*
* @param string
*/
private function mergeRanges(&$In)
{
while (true) {
Expand Down Expand Up @@ -478,7 +518,11 @@ private function mergeRanges(&$In)
}
}

/** Optionally converts output to netmask notation. */
/**
* Optionally converts output to netmask notation.
*
* @param string
*/
private function convertToNetmasks(&$In)
{
if (isset($this->callbacks['newParse']) && is_callable($this->callbacks['newParse'])) {
Expand Down

0 comments on commit 12f0121

Please sign in to comment.