DNSQueryProfiled   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getProfile() 0 3 1
A __construct() 0 3 1
A getName() 0 3 1
A toArray() 0 6 1
1
<?php
2
3
namespace RemotelyLiving\PHPDNS\Observability\Events;
4
5
use RemotelyLiving\PHPDNS\Observability\Performance\Interfaces\ProfileInterface;
6
use RemotelyLiving\PHPDNS\Observability\Performance\Profile;
7
8
final class DNSQueryProfiled extends ObservableEventAbstract
9
{
10
    public const NAME = 'dns.query.profiled';
11
12
    public function __construct(private ProfileInterface $profile)
13
    {
14
        parent::__construct();
15
    }
16
17
    public function getProfile(): ProfileInterface
18
    {
19
        return $this->profile;
20
    }
21
22
    public static function getName(): string
23
    {
24
        return self::NAME;
25
    }
26
27
    public function toArray(): array
28
    {
29
        return [
30
            'elapsedSeconds' => $this->profile->getElapsedSeconds(),
31
            'transactionName' => $this->profile->getTransactionName(),
32
            'peakMemoryUsage' => $this->profile->getPeakMemoryUsage(),
33
        ];
34
    }
35
}
36