LoggerAwareTrait::setLogger()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
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