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

LoggerUtilFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 53.33%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 29
ccs 8
cts 15
cp 0.5333
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getLoggerUtil() 0 11 2
A getPirateLogger() 0 9 1
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