remotelyliving /
php-dns
| 1 | <?php |
||
| 2 | |||
| 3 | namespace RemotelyLiving\PHPDNS\Observability\Traits; |
||
| 4 | |||
| 5 | use Psr\Log\LoggerInterface; |
||
| 6 | use Psr\Log\NullLogger; |
||
| 7 | |||
| 8 | trait Logger |
||
| 9 | { |
||
| 10 | private ?LoggerInterface $logger = null; |
||
| 11 | |||
| 12 | public function setLogger(LoggerInterface $logger): void |
||
| 13 | { |
||
| 14 | $this->logger = $logger; |
||
| 15 | } |
||
| 16 | |||
| 17 | protected function getLogger(): LoggerInterface |
||
| 18 | { |
||
| 19 | if ($this->logger === null) { |
||
| 20 | $this->logger = new NullLogger(); |
||
| 21 | } |
||
| 22 | |||
| 23 | return $this->logger; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 24 | } |
||
| 25 | } |
||
| 26 |