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

VarDumperCollector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A collectVar() 0 5 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 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