IPv6   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getLong() 0 8 2
A __construct() 0 3 1
1
<?php
2
3
namespace devtoolboxuk\internetaddress;
4
5
class IPv6 extends IP
6
{
7
    const version = 'IPv6';
8
    const length = 128;
9
    const octets = 16;
10
11
    public function __construct($ip)
12
    {
13
        parent::__construct($ip);
14
    }
15
16
    public function getLong($ip_addr)
17
    {
18
        $long = 0;
19
        $octet = IPv6::octets - 1;
20
        foreach ($chars = unpack('C*', $ip_addr) as $char) {
0 ignored issues
show
Unused Code introduced by
The assignment to $chars is dead and can be removed.
Loading history...
21
            $long = bcadd($long, bcmul($char, bcpow(256, $octet--)));
22
        }
23
        return $long;
24
    }
25
26
}