VarDumperCollector   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A collect() 0 7 1
A getCollected() 0 7 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(
14
        private readonly TimelineCollector $timelineCollector
15
    ) {
16
    }
17
18
    public function collect(mixed $variable, string $line): void
19
    {
20
        $this->vars[] = [
21
            'variable' => $variable,
22
            'line' => $line,
23
        ];
24
        $this->timelineCollector->collect($this, count($this->vars));
25
    }
26
27
    public function getCollected(): array
28
    {
29
        if (!$this->isActive()) {
30
            return [];
31
        }
32
33
        return $this->vars;
34
    }
35
36
    public function getSummary(): array
37
    {
38
        if (!$this->isActive()) {
39
            return [];
40
        }
41
42
        return [
43
            'var-dumper' => [
44
                'total' => count($this->vars),
45
            ],
46
        ];
47
    }
48
}
49