-
-
Notifications
You must be signed in to change notification settings - Fork 44
Add split
Method to Subnet for Dividing Network Ranges into Smaller Subnets
#93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to increase the minimum supported PHP version?
Hi @mlocati, Thank you for reviewing my pull request. To handle large IP ranges efficiently, I used a generator class. This suggestion is from the IDE, recommending that the PHP version be updated to at least 5.5. |
Yel, generators require PHP 5.5. But I don't think I'd increase the minimum PHP version just for this reason |
5fb0bc0
to
f2140fb
Compare
I have updated the code to return an array instead of a generator instance. |
I'd
|
bfc609c
to
fadd122
Compare
fadd122
to
625bf47
Compare
Hi @mlocati, Do you have any feedback on this pull request? |
@alissn The automated actions already gave you a feedback 😉 - see https://github.com/mlocati/ip-lib/pull/93/checks |
@mlocati However, PHP 5.3, 5.4, and 5.5 are no longer relevant for me and many others. 🙂 |
@alissn I've updated the code of this pull request. |
Also: please add some tests for the Single and Pattern classes (I don't think we need new test methods: adding cases to the two existing providers should be enough) |
@mlocati However, when passing a pattern-based range to the |
edf7deb
to
410ce39
Compare
$systemBitness = PHP_INT_SIZE * 8;
$minPrefixByBitness = $maxPrefix - $systemBitness + 2;
if ($minPrefixByBitness > $networkPrefix) {
throw new OverflowException("The value of \$networkPrefix leads to too large ranges for the current machine bitness (you can use a value of at least {$minPrefixByBitness})");
} I removed this section because the Additionally, an error is already handled in the following section: if ($networkPrefix < $myNetworkPrefix) {
throw new OutOfBoundsException("The value of the \$networkPrefix parameter can't be smaller than the network prefix of the range ({$myNetworkPrefix})");
} |
You shouldn't remove the chunk of code that throws an OverflowException: it handles the case when pow(2, ...) returns a non-integer value |
84a5e41
to
410ce39
Compare
Reverted the change, but I couldn't add a test for it. If you can, please add a test case to ensure the exception is thrown. |
It's already there: ip-lib/test/tests/Ranges/RangesSplitTest.php Line 588 in 410ce39
|
Based on the coverage report here this code path isn't covered by tests. |
We send to Coveralls only one coverage, and it's for a case where we use a 64- bit PHP. |
This implies checking $networkPrefix for Single::split() too, without efforts
915626f
to
f8653b8
Compare
Thanks! |
Hi,
This pull request introduces a new
split
method to theIPLib\Range\Subnet
class, enabling the division of a network range into smaller subnets. This feature supports both IPv4 and IPv6, making it versatile for various networking scenarios.Usage
Result
Key Benefits
Let me know if additional details or adjustments are needed!