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

LoggerUtilFactory::getPirateLogger()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

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