Passed
Push — master ( f7ef7a...65c26d )
by Dmitriy
02:46
created

LogCollector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 90.91%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 36
ccs 10
cts 11
cp 0.9091
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCollected() 0 3 1
A collect() 0 12 2
A reset() 0 3 1
A getSummary() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Collector;
6
7
class LogCollector implements SummaryCollectorInterface
8
{
9
    use CollectorTrait;
10
11
    private array $messages = [];
12
13 2
    public function getCollected(): array
14
    {
15 2
        return $this->messages;
16
    }
17
18 2
    public function collect(string $level, $message, array $context, string $line): void
19
    {
20 2
        if (!$this->isActive()) {
21
            return;
22
        }
23
24 2
        $this->messages[] = [
25 2
            'time' => microtime(true),
26
            'level' => $level,
27
            'message' => $message,
28
            'context' => $context,
29
            'line' => $line,
30
        ];
31
    }
32
33 1
    private function reset(): void
0 ignored issues
show
Unused Code introduced by
The method reset() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
34
    {
35 1
        $this->messages = [];
36
    }
37
38 1
    public function getSummary(): array
39
    {
40
        return [
41
            'logger' => [
42 1
                'total' => count($this->messages),
43
            ],
44
        ];
45
    }
46
}
47