| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | 12 | public function ip2long($ip) |
|
| 13 | { |
||
| 14 | 12 | if (!$this->validateIp($ip)) { |
|
| 15 | 1 | return false; |
|
| 16 | } |
||
| 17 | |||
| 18 | 11 | $parts = explode('.', $ip); |
|
| 19 | 11 | $sumParts = array(); |
|
| 20 | 11 | $partIndex = 0; |
|
| 21 | 11 | for ($exponent = 3; $exponent >= 0; $exponent--) { |
|
| 22 | 11 | $sumParts[] = pow(256, $exponent) * $parts[$partIndex]; |
|
| 23 | 11 | $partIndex++; |
|
| 24 | 11 | } |
|
| 25 | |||
| 26 | 11 | return array_sum($sumParts); |
|
| 27 | } |
||
| 28 | |||
| 45 |