Completed
Pull Request — master (#27)
by Christian
02:13
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
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