Issues (14)

library/IPv6.php (1 issue)

Severity
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
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
}