Passed
Pull Request — master (#223)
by Dmitriy
02:43
created

VarDumperCollector::getCollected()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 8
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 collectVar(mixed $variable, string $line): void
14
    {
15
        $this->vars[] = [
16
            'variable' => $variable,
17
            'line' => $line,
18
        ];
19
    }
20
21
    public function getCollected(): array
22
    {
23
        if (!$this->isActive()) {
24
            return [];
25
        }
26
27
        return [
28
            'var-dumper' => $this->vars,
29
        ];
30
    }
31
32
    public function getSummary(): array
33
    {
34
        if (!$this->isActive()) {
35
            return [];
36
        }
37
38
        return [
39
            'var-dumper' => [
40
                'total' => count($this->vars),
41
            ],
42
        ];
43
    }
44
}
45