Skip to content

Commit

Permalink
Stricter typing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maikuolan committed Oct 14, 2024
1 parent 178757d commit 6fd8904
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Versioning guidelines for SemVer can be found at: https://semver.org/

- [2024.08.02; Maikuolan]: Fixed some typos.

- [2024.10.14]: Strictened typing for the aggregator.

=== Version/Release 1.3.4 ===
PATCH RELEASE.

Expand Down
17 changes: 9 additions & 8 deletions src/Aggregator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Aggregator v1.3.5 (last modified: 2024.06.25).
* Aggregator v1.3.5 (last modified: 2024.10.14).
* @link https://github.com/CIDRAM/Aggregator
*
* Description: A stand-alone class implementation of the IPv4+IPv6 IP+CIDR
Expand Down Expand Up @@ -107,13 +107,16 @@ public function __construct($Mode = 0)
/**
* Aggregate it!
*
* @param string|array $In The IPs/CIDRs/netmasks to be aggregated. Should
* either be a string, with entries separated by lines, or an
* array with an entry to each element.
* @param string $In The IPs/CIDRs/netmasks to be aggregated. Entries separated by lines.
* @return string The aggregated data.
*/
public function aggregate($In)
{
/** Guard. */
if (!is_string($In)) {
return '';
}

$Begin = microtime(true);
$this->Output = $In;
$this->stripInvalidCharactersAndSort($this->Output);
Expand Down Expand Up @@ -173,14 +176,12 @@ private function constructTables()
/**
* Strips invalid characters from lines and sorts entries.
*
* @param string|array
* @param string
* @return void
*/
private function stripInvalidCharactersAndSort(&$In)
{
if (!is_array($In)) {
$In = explode("\n", strtolower(trim(str_replace("\r", '', $In))));
}
$In = explode("\n", strtolower(trim(str_replace("\r", '', $In))));
$InCount = count($In);
if (isset($this->callbacks['newParse']) && is_callable($this->callbacks['newParse'])) {
$this->callbacks['newParse']($InCount);
Expand Down

0 comments on commit 6fd8904

Please sign in to comment.