LoggerAwareTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 10
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A setLogger() 0 6 1
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Helpers/LoggerAwareTrait.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Helpers;
10
11
use Psr\Log\LoggerInterface;
12
use Symfony\Contracts\Service\Attribute\Required;
13
14
/**
15
 * Trait LoggerAwareTrait
16
 *
17
 * NOTE: Do not use this in your services, just inject `LoggerInterface` to
18
 *       service where you need it. This trait is just for quick debug purposes
19
 *       and nothing else.
20
 *
21
 * @package App\Helpers
22
 * @author TLe, Tarmo Leppänen <[email protected]>
23
 */
24
trait LoggerAwareTrait
25
{
26
    protected ?LoggerInterface $logger = null;
27
28 1
    #[Required]
29
    public function setLogger(LoggerInterface $logger): self
30
    {
31 1
        $this->logger = $logger;
32
33 1
        return $this;
34
    }
35
}
36