Passed
Push — master ( bf860f...1dd8f7 )
by Nico
57:55 queued 29:36
created

LoggerUtilFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 93.75%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 11
dl 0
loc 31
ccs 15
cts 16
cp 0.9375
rs 10
c 1
b 1
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getLoggerUtil() 0 11 2
A getPirateLogger() 0 10 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Logging;
6
7
use JBBCode\Parser;
8
use Stu\Module\Config\StuConfigInterface;
9
10
final class LoggerUtilFactory implements LoggerUtilFactoryInterface
11
{
12 4
    public function __construct(
13
        private StuConfigInterface $config,
14
        private Parser $parser
15
    ) {
16 4
    }
17
18 4
    public function getLoggerUtil(bool $doDefaultInit = false): LoggerUtilInterface
19
    {
20 4
        $loggerUtil = new LoggerUtil(
21 4
            $this->config
22 4
        );
23
24 4
        if ($doDefaultInit) {
25
            $loggerUtil->init('STU', LoggerEnum::LEVEL_ERROR);
26
        }
27
28 4
        return $loggerUtil;
29
    }
30
31 1
    public function getPirateLogger(): PirateLoggerInterface
32
    {
33 1
        $loggerUtil = new PirateLogger(
34 1
            $this->config,
35 1
            $this->parser
36 1
        );
37
38 1
        $loggerUtil->initRotating();
39
40 1
        return $loggerUtil;
41
    }
42
}
43