Passed
Pull Request — 1.x (#99)
by Akihito
10:41
created

RepositoryLogger::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

39
        return implode(PHP_EOL, /** @scrutinizer ignore-type */ $this->logs);
Loading history...
40
    }
41
}
42