1 | <?php |
||
2 | |||
3 | namespace RemotelyLiving\PHPDNS\Observability\Traits; |
||
4 | |||
5 | use RemotelyLiving\PHPDNS\Observability\Performance\Profile; |
||
6 | use RemotelyLiving\PHPDNS\Observability\Performance\ProfileFactory; |
||
7 | |||
8 | trait Profileable |
||
9 | { |
||
10 | private ?ProfileFactory $profileFactory = null; |
||
11 | |||
12 | public function createProfile(string $transactionName): Profile |
||
13 | { |
||
14 | return $this->getProfileFactory()->create($transactionName); |
||
15 | } |
||
16 | |||
17 | public function setProfileFactory(ProfileFactory $profileFactory): void |
||
18 | { |
||
19 | $this->profileFactory = $profileFactory; |
||
20 | } |
||
21 | |||
22 | private function getProfileFactory(): ProfileFactory |
||
23 | { |
||
24 | if ($this->profileFactory === null) { |
||
25 | $this->profileFactory = new ProfileFactory(); |
||
26 | } |
||
27 | |||
28 | return $this->profileFactory; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
29 | } |
||
30 | } |
||
31 |