IPv6::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
}