Conditions | 1 |
Paths | 1 |
Total Lines | 11 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | public function match($value) |
||
22 | { |
||
23 | // Adapted from https://gist.github.com/tott/7684443 |
||
24 | |||
25 | list($range, $netmask) = explode('/', $this->_definition, 2); |
||
26 | $rangeDecimal = ip2long($range); |
||
27 | $ipDecimal = ip2long($value); |
||
28 | $wildcardDecimal = pow(2, (32 - $netmask)) - 1; |
||
29 | $netmaskDecimal = ~$wildcardDecimal; |
||
30 | |||
31 | return (($ipDecimal & $netmaskDecimal) == ($rangeDecimal & $netmaskDecimal)); |
||
32 | } |
||
34 |