Completed
Branch Message (d15af3)
by Sam
05:12
created

AAAA::fromWire()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 3
dl 0
loc 11
ccs 6
cts 7
cp 0.8571
crap 2.0116
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Badcow DNS Library.
7
 *
8
 * (c) Samuel Williams <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Badcow\DNS\Rdata;
15
16
/**
17
 * @see https://tools.ietf.org/html/rfc3596#section-2.1
18
 */
19
class AAAA extends A
20
{
21
    const TYPE = 'AAAA';
22
    const TYPE_CODE = 28;
23
24
    /**
25
     * {@inheritdoc}
26
     *
27
     * @throws DecodeException
28
     */
29 2
    public static function fromWire(string $rdata, int &$offset = 0, ?int $rdLength = null): RdataInterface
30
    {
31 2
        if (false === $address = @inet_ntop(substr($rdata, $offset, 16))) {
32
            throw new DecodeException(static::TYPE, $rdata);
33
        }
34 2
        $offset += 16;
35
36 2
        $a = new static();
37 2
        $a->setAddress($address);
38
39 2
        return $a;
40
    }
41
}
42