VarDumperCollector::getCollected()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 0
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(
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