GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( 405cf3...79c9ba )
by Joni
04:48
created

IPv4Address   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 41
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A _octets() 0 8 2
A fromOctets() 0 16 4
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\X509\GeneralName;
6
7
class IPv4Address extends IPAddress
8
{
9
    /**
10
     * Initialize from octets.
11
     *
12
     * @param string $octets
13
     *
14
     * @throws \InvalidArgumentException
15
     *
16 11
     * @return self
17
     */
18 11
    public static function fromOctets(string $octets): self
19 11
    {
20 11
        $mask = null;
21 11
        $bytes = unpack('C*', $octets) ?: [];
22 9
        switch (count($bytes)) {
23 9
            case 4:
24 2
                $ip = implode('.', $bytes);
25 1
                break;
26 1
            case 8:
27 1
                $ip = implode('.', array_slice($bytes, 0, 4));
28
                $mask = implode('.', array_slice($bytes, 4, 4));
29 1
                break;
30
            default:
31 10
                throw new \UnexpectedValueException('Invalid IPv4 octet length.');
32
        }
33
        return new self($ip, $mask);
34
    }
35
36
    /**
37
     * {@inheritdoc}
38 16
     */
39
    protected function _octets(): string
40 16
    {
41 16
        $bytes = array_map('intval', explode('.', $this->_ip));
42 1
        if (isset($this->_mask)) {
43 1
            $bytes = array_merge($bytes,
44
                array_map('intval', explode('.', $this->_mask)));
45 16
        }
46
        return pack('C*', ...$bytes);
47
    }
48
}
49