DNSQueryFailed   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 45
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getError() 0 3 1
A getName() 0 3 1
A getResolver() 0 3 1
A getHostName() 0 3 1
A getRecordType() 0 3 1
A toArray() 0 7 1
1
<?php
2
3
namespace RemotelyLiving\PHPDNS\Observability\Events;
4
5
use RemotelyLiving\PHPDNS\Entities\DNSRecordType;
6
use RemotelyLiving\PHPDNS\Entities\Hostname;
7
use RemotelyLiving\PHPDNS\Exceptions\Exception;
8
use RemotelyLiving\PHPDNS\Resolvers\Interfaces\Resolver;
9
10
final class DNSQueryFailed extends ObservableEventAbstract
11
{
12
    public const NAME = 'dns.query.failed';
13
14
    public function __construct(
15
        private Resolver $resolver,
16
        private Hostname $hostname,
17
        private DNSRecordType $recordType,
18
        private Exception $error
19
    ) {
20
        parent::__construct();
21
    }
22
23
    public function getResolver(): Resolver
24
    {
25
        return $this->resolver;
26
    }
27
28
    public function getHostName(): Hostname
29
    {
30
        return $this->hostname;
31
    }
32
33
    public function getRecordType(): DNSRecordType
34
    {
35
        return $this->recordType;
36
    }
37
38
    public function getError(): Exception
39
    {
40
        return $this->error;
41
    }
42
43
    public static function getName(): string
44
    {
45
        return self::NAME;
46
    }
47
48
    public function toArray(): array
49
    {
50
        return [
51
            'resolver' => $this->resolver->getName(),
52
            'hostname' => (string)$this->hostname,
53
            'type' => (string)$this->recordType,
54
            'error' => $this->error,
55
        ];
56
    }
57
}
58