Passed
Push — dev ( c4f015...eeaa0f )
by Janko
27:51
created

PirateLogger::logf()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Logging;
6
7
use JBBCode\Parser;
8
use Monolog\Handler\RotatingFileHandler;
9
use Monolog\Logger;
10
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Stu\Module\Config\StuConfigInterface;
12
13
final class PirateLogger implements PirateLoggerInterface
14
{
15
    private ?Logger $logger = null;
16
17 1
    public function __construct(
18
        private StuConfigInterface $stuConfig,
19
        private Parser $parser
20
    ) {
21 1
    }
22
23 1
    #[Override]
24
    public function initRotating(): void
25
    {
26 1
        $this->logger = new Logger('KAZON');
27 1
        $this->logger->pushHandler(
28 1
            new RotatingFileHandler(
29 1
                $this->stuConfig->getGameSettings()->getPirateLogfilePath()
30 1
            ),
31 1
        );
32
    }
33
34
    #[Override]
35
    public function log(string $message): void
36
    {
37
        $method = LoggerEnum::LEVEL_METHODS[LoggerEnum::LEVEL_INFO];
0 ignored issues
show
Bug introduced by
The type Stu\Module\Logging\LoggerEnum was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
38
        $this->logger->$method(
39
            $this->parser->parse($message)->getAsText()
40
        );
41
    }
42
43
    #[Override]
44
    public function logf(string $information, ...$args): void
45
    {
46
        $this->log(vsprintf(
47
            $information,
48
            $args
49
        ));
50
    }
51
}
52