RepositoryLogger::log()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 6
c 1
b 0
f 0
nc 4
nop 2
dl 0
loc 14
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\QueryRepository;
6
7
use Stringable;
8
9
use function implode;
10
use function is_array;
11
use function sprintf;
12
13
use const PHP_EOL;
14
15
final class RepositoryLogger implements RepositoryLoggerInterface, Stringable
16
{
17
    /** @var list<string> */
0 ignored issues
show
Bug introduced by
The type BEAR\QueryRepository\list 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...
18
    private array $logs = [];
19
20
    /**
21
     * {@inheritDoc}
22
     */
23
    public function log(string $template, ...$values): void
24
    {
25
        /** @var bool|float|int|string|list<string>|null $value */
26
        foreach ($values as &$value) {
27
            if (is_array($value)) {
28
                $value = $value !== [] ? implode(' ', $value) : '';
29
            }
30
        }
31
32
        unset($value);
33
        /** @var list<string> $values */
34
        $msg = sprintf($template, ...$values);
35
36
        $this->logs[] = $msg;
37
    }
38
39
    public function __toString(): string
40
    {
41
        return implode(PHP_EOL, $this->logs);
42
    }
43
}
44