Completed
Push — master ( cc9218...491824 )
by Christian
08:17 queued 10s
created

Dig   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A toDNSRecord() 0 19 3
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