Passed
Push — master ( f7ef7a...65c26d )
by Dmitriy
02:46
created

AssetCollector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 12
dl 0
loc 34
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A reset() 0 3 1
A collect() 0 7 2
A getCollected() 0 3 1
A getSummary() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Collector\Web;
6
7
use Yiisoft\Assets\AssetBundle;
8
use Yiisoft\Yii\Debug\Collector\CollectorTrait;
9
use Yiisoft\Yii\Debug\Collector\SummaryCollectorInterface;
10
11
final class AssetCollector implements SummaryCollectorInterface
12
{
13
    use CollectorTrait;
14
15
    private array $assetBundles = [];
16
17
    public function getCollected(): array
18
    {
19
        return $this->assetBundles;
20
    }
21
22
    public function collect(AssetBundle $assetBundle): void
23
    {
24
        if (!$this->isActive()) {
25
            return;
26
        }
27
28
        $this->assetBundles[] = $assetBundle;
29
    }
30
31
    public function getSummary(): array
32
    {
33
        return [
34
            'asset' => [
35
                'bundles' => [
36
                    'total' => count($this->assetBundles),
37
                ],
38
            ],
39
        ];
40
    }
41
42
    private function reset(): void
0 ignored issues
show
Unused Code introduced by
The method reset() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
43
    {
44
        $this->assetBundles = [];
45
    }
46
}
47