Completed
Push — master ( cc9218...491824 )
by Christian
08:17 queued 10s
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
8
class Dig extends MapperAbstract
9
{
10
    public function toDNSRecord(): DNSRecord
11
    {
12
        $type = new DNSRecordType($this->fields[3]);
13
        if ($type->isA(DNSRecordType::TYPE_A) || $type->isA(DNSRecordType::TYPE_AAAA)) {
14
            return DNSRecord::createFromPrimitives(
15
                $this->fields[3],
16
                (string)$this->fields[0],
17
                (int)$this->fields[1],
18
                $this->fields[4]
19
            );
20
        }
21
22
        return DNSRecord::createFromPrimitives(
23
            $this->fields[3],
24
            (string)$this->fields[0],
25
            (int)$this->fields[1],
26
            null,
27
            'IN',
28
            $this->fields[4]
29
        );
30
    }
31
}
32