Completed
Pull Request — master (#27)
by Christian
02:13
created

Dig::toDNSRecord()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 14
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 19
rs 9.7998
1
<?php
2
3
namespace RemotelyLiving\PHPDNS\Mappers;
4
5
use RemotelyLiving\PHPDNS\Entities\DNSRecord;
6
use RemotelyLiving\PHPDNS\Entities\DNSRecordType;
7
use RemotelyLiving\PHPDNS\Exceptions\InvalidArgumentException;
8
9
class Dig extends MapperAbstract
10
{
11
    public function toDNSRecord(): DNSRecord
12
    {
13
        $type = new DNSRecordType($this->fields[3]);
14
        if ($type->isA(DNSRecordType::TYPE_A) || $type->isA(DNSRecordType::TYPE_AAAA)) {
15
            return DNSRecord::createFromPrimitives(
16
                $this->fields[3],
17
                (string)$this->fields[0],
18
                (int)$this->fields[1],
19
                $this->fields[4]
20
            );
21
        }
22
23
        return DNSRecord::createFromPrimitives(
24
            $this->fields[3],
25
            (string)$this->fields[0],
26
            (int)$this->fields[1],
27
            null,
28
            'IN',
29
            $this->fields[4]
30
        );
31
    }
32
}
33