Passed
Pull Request — master (#1779)
by Nico
49:51 queued 23:55
created

LoggerUtilFactory::getPirateLogger()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 9
ccs 0
cts 6
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Logging;
6
7
use Stu\Module\Config\StuConfigInterface;
8
9
final class LoggerUtilFactory implements LoggerUtilFactoryInterface
10
{
11 4
    public function __construct(
12
        private StuConfigInterface $config
13
    ) {
14 4
    }
15
16 4
    public function getLoggerUtil(bool $doDefaultInit = false): LoggerUtilInterface
17
    {
18 4
        $loggerUtil = new LoggerUtil(
19 4
            $this->config
20 4
        );
21
22 4
        if ($doDefaultInit) {
23
            $loggerUtil->init('STU', LoggerEnum::LEVEL_ERROR);
24
        }
25
26 4
        return $loggerUtil;
27
    }
28
29
    public function getPirateLogger(): PirateLoggerInterface
30
    {
31
        $loggerUtil = new PirateLogger(
32
            $this->config
33
        );
34
35
        $loggerUtil->initRotating();
36
37
        return $loggerUtil;
38
    }
39
}
40