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

VarDumperCollector::collect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 7
rs 10
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