Passed
Push — master ( 755731...71ac2a )
by Dmitriy
02:36
created

VarDumperCollector   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A collect() 0 7 1
A getCollected() 0 8 2
A getSummary() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Collector;
6
7
final class VarDumperCollector implements SummaryCollectorInterface
8
{
9
    use CollectorTrait;
10
11
    private array $vars = [];
12
13
    public function __construct(private TimelineCollector $timelineCollector)
14
    {
15
    }
16
17
    public function collect(mixed $variable, string $line): void
18
    {
19
        $this->vars[] = [
20
            'variable' => $variable,
21
            'line' => $line,
22
        ];
23
        $this->timelineCollector->collect($this, count($this->vars));
24
    }
25
26
    public function getCollected(): array
27
    {
28
        if (!$this->isActive()) {
29
            return [];
30
        }
31
32
        return [
33
            'var-dumper' => $this->vars,
34
        ];
35
    }
36
37
    public function getSummary(): array
38
    {
39
        if (!$this->isActive()) {
40
            return [];
41
        }
42
43
        return [
44
            'var-dumper' => [
45
                'total' => count($this->vars),
46
            ],
47
        ];
48
    }
49
}
50