The class Range has 11 public methods. Consider refactoring Range to keep number of public methods under 10. Open
class Range implements \Iterator, \Countable
{
use PropertyTrait;
/**
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class Range has an overall complexity of 53 which is very high. The configured complexity threshold is 50. Open
class Range implements \Iterator, \Countable
{
use PropertyTrait;
/**
- Exclude checks
The method getNetworks() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function getNetworks()
{
$span = $this->getSpanNetwork();
$networks = array();
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Avoid using static access to class 'IPTools\IP' in method 'getSpanNetwork'. Open
$ip = IP::parseBin(str_pad(substr($this->getFirstIP()->toBin(), 0, $prefixLength), $xorIP->getMaxPrefixLength(), '0'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'IPTools\IP' in method 'getSpanNetwork'. Open
$xorIP = IP::parseInAddr($this->getFirstIP()->inAddr() ^ $this->getLastIP()->inAddr());
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method contains uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new RangeException('Invalid type');
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'IPTools\IP' in method 'parse'. Open
$firstIP = IP::parse($first);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'IPTools\IP' in method 'parse'. Open
$lastIP = IP::parse($last);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'IPTools\Network' in method 'parse'. Open
$network = Network::parse($data);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method parse uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$firstIP = IP::parse($data);
$lastIP = clone $firstIP;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'IPTools\IP' in method 'parse'. Open
$firstIP = IP::parse($data);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'IPTools\Network' in method 'getSpanNetwork'. Open
return new Network($ip, Network::prefix2netmask($prefixLength, $ip->getVersion()));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'IPTools\IP' in method 'parse'. Open
$lastIP = IP::parse(str_replace('*', '255', $data));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method getNetworks uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if ($span->getFirstIP()->inAddr() !== $this->firstIP->inAddr()) {
$excluded = $span->exclude($this->firstIP->prev());
foreach ($excluded as $network) {
if (strcmp($network->getFirstIP()->inAddr(), $this->firstIP->inAddr()) >= 0) {
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'IPTools\IP' in method 'parse'. Open
$firstIP = IP::parse(str_replace('*', '0', $data));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method getNetworks uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$excluded = array_pop($networks);
$excluded = $excluded->exclude($this->lastIP->next());
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($find instanceof IP) {
/**
* @var IP $find
*/
$within = (strcmp($find->inAddr(), $this->firstIP->inAddr()) >= 0)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 144.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($find instanceof IP) {
/**
* @var IP $find
*/
$within = (strcmp($find->inAddr(), $this->firstIP->inAddr()) >= 0)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 144.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid variables with short names like $ip. Configured minimum length is 3. Open
$ip = IP::parseBin(str_pad(substr($this->getFirstIP()->toBin(), 0, $prefixLength), $xorIP->getMaxPrefixLength(), '0'));
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $ip. Configured minimum length is 3. Open
public function setFirstIP(IP $ip)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $ip. Configured minimum length is 3. Open
public function setLastIP(IP $ip)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Blank line found at end of control structure Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$firstIP = IP::parse($first);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var Network|Range $find
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($find instanceof Range || $find instanceof Network) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $firstIP;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($find instanceof Range || $find instanceof Network) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct(IP $firstIP, IP $lastIP)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setFirstIP($firstIP);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($find instanceof IP) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var IP $find
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (strpos($data,'/') || strpos($data,' ')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$firstIP = $network->getFirstIP();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& (strcmp($find->inAddr(), $this->lastIP->inAddr()) <= 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($findArray as $find) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setLastIP($lastIP);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $data
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Range
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return new self($firstIP, $lastIP);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws RangeException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$within = (strcmp($find->getFirstIP()->inAddr(), $this->firstIP->inAddr()) >= 0)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($find instanceof IP) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var IP $find
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& (strcmp($find->getLastIP()->inAddr(), $this->lastIP->inAddr()) <= 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Same as contains but works on an array of IP|Network|Range and returns true if all of the array items are in the range
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lastIP = IP::parse($last);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lastIP = clone $firstIP;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& (strcmp($find->getLastIP()->inAddr(), $this->lastIP->inAddr()) <= 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (strpos($data, '-')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param IP|Network|Range $find
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var Network|Range $find
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Same as contains but works on an array of IP|Network|Range and returns true if any of the array items are in the range
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var IP
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($within) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var IP
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $lastIP;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function parse($data)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$firstIP = IP::parse($data);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function contains($find)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lastIP = IP::parse(str_replace('*', '255', $data));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$within = (strcmp($find->inAddr(), $this->firstIP->inAddr()) >= 0)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
list($first, $last) = explode('-', $data, 2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new RangeException('Invalid type');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lastIP = $network->getLastIP();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$firstIP = IP::parse(str_replace('*', '0', $data));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $findArray
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$within = (strcmp($find->inAddr(), $this->firstIP->inAddr()) >= 0)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& (strcmp($find->inAddr(), $this->lastIP->inAddr()) <= 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
use PropertyTrait;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $within;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \Exception
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$within = (strcmp($find->getFirstIP()->inAddr(), $this->firstIP->inAddr()) >= 0)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $position = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param IP $firstIP
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param IP $lastIP
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws RangeException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$network = Network::parse($data);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (strpos($data, '*') !== false) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function containsAny($findArray)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new RangeException('First IP is grater than second');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setLastIP(IP $ip)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($excluded as $network) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& $span->getLastIP()->inAddr() === $this->lastIP->inAddr()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->firstIP->next($this->position);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
#[ReturnTypeWillChange]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFirstIP()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (strcmp($network->getFirstIP()->inAddr(), $this->firstIP->inAddr()) >= 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$xorIP = IP::parseInAddr($this->getFirstIP()->inAddr() ^ $this->getLastIP()->inAddr());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
#[ReturnTypeWillChange]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$within = (strcmp($find->inAddr(), $this->firstIP->inAddr()) >= 0)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param IP $ip
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function containsAll($findArray)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ip = IP::parseBin(str_pad(substr($this->getFirstIP()->toBin(), 0, $prefixLength), $xorIP->getMaxPrefixLength(), '0'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function current()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->lastIP;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function next()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($span->getFirstIP()->inAddr() === $this->firstIP->inAddr()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$excluded = $span->exclude($this->firstIP->prev());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Network
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$prefixLength = strlen($match[1]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function valid()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($findArray as $find) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$within) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws RangeException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setFirstIP(IP $ip)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$networks[] = $network;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
#[ReturnTypeWillChange]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->lastIP && strcmp($ip->inAddr(), $this->lastIP->inAddr()) > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($network->getLastIP()->inAddr() === $this->lastIP->inAddr()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getSpanNetwork()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return IP
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getNetworks()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$excluded = $excluded->exclude($this->lastIP->next());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $networks;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
#[ReturnTypeWillChange]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$this->position;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return strcmp($this->firstIP->next($this->position)->inAddr(), $this->lastIP->inAddr()) <= 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $findArray
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var Network|Range $find
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$within = (strcmp($find->getFirstIP()->inAddr(), $this->firstIP->inAddr()) >= 0)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param IP $ip
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$networks = array();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$networks = array($span);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($excluded as $network) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$excluded = $span->exclude($this->lastIP->next());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match('/^(0*)/', $xorIP->toBin(), $match);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->position = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
#[ReturnTypeWillChange]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var IP $find
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws RangeException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->lastIP = $ip;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
#[ReturnTypeWillChange]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return IP
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->position;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function rewind()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($find instanceof IP) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& (strcmp($find->inAddr(), $this->lastIP->inAddr()) <= 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& (strcmp($find->getLastIP()->inAddr(), $this->lastIP->inAddr()) <= 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->firstIP && strcmp($ip->inAddr(), $this->firstIP->inAddr()) < 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return IP
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Network[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$networks[] = $network;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function key()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->firstIP = $ip;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new RangeException('Last IP is less than first');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$span = $this->getSpanNetwork();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return new Network($ip, Network::prefix2netmask($prefixLength, $ip->getVersion()));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \Exception
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->firstIP;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getLastIP()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$excluded = array_pop($networks);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($find instanceof Range || $find instanceof Network) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($span->getFirstIP()->inAddr() !== $this->firstIP->inAddr()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($span->getLastIP()->inAddr() !== $this->lastIP->inAddr()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$networks) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function count()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (integer)bcadd(bcsub($this->lastIP->toLong(), $this->firstIP->toLong()), 1);
- Exclude checks
Whitespace found at end of line Open
* Same as contains but works on an array of IP|Network|Range and returns true if any of the array items are in the range
- Exclude checks
Whitespace found at end of line Open
* Same as contains but works on an array of IP|Network|Range and returns true if all of the array items are in the range
- Exclude checks
Whitespace found at end of line Open
*
- Exclude checks
No space found after comma in function call Open
if (strpos($data,'/') || strpos($data,' ')) {
- Exclude checks
No space found after comma in function call Open
if (strpos($data,'/') || strpos($data,' ')) {
- Exclude checks
Whitespace found at end of line Open
*
- Exclude checks