Test Failed
Pull Request — dev (#1952)
by Janko
02:59
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 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 6
ccs 0
cts 0
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 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 RuntimeException;
12
use Stu\Module\Config\StuConfigInterface;
13
14
final class PirateLogger implements PirateLoggerInterface
15
{
16 2
    private ?Logger $logger = null;
17
18 2
    public function __construct(
19
        private StuConfigInterface $stuConfig,
20 2
        private Parser $parser
21
    ) {}
22
23 2
    #[Override]
24
    public function initRotating(): void
25
    {
26 1
        $this->logger = new Logger('KAZON');
27
        $this->logger->pushHandler(
28
            new RotatingFileHandler(
29 1
                $this->stuConfig->getGameSettings()->getPirateSettings()->getPirateLogfilePath()
30
            ),
31
        );
32
    }
33 1
34
    #[Override]
35
    public function log(string $message): void
36 1
    {
37
        if ($this->logger === null) {
38
            throw new RuntimeException('logger has not been initialized');
39 1
        }
40 1
41 1
        $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...
42 1
        $this->logger->$method(
43
            $this->parser->parse($message)->getAsText()
44
        );
45
    }
46
47
    #[Override]
48
    public function logf(string $information, ...$args): void
49
    {
50
        $this->log(vsprintf(
51
            $information,
52
            $args
53
        ));
54
    }
55
}
56