Passed
Push — master ( 33d5ac...775805 )
by Dmitriy
03:03
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 getIndexData() 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\CollectorInterface;
9
use Yiisoft\Yii\Debug\Collector\CollectorTrait;
10
use Yiisoft\Yii\Debug\Collector\IndexCollectorInterface;
11
12
final class AssetCollector implements CollectorInterface, IndexCollectorInterface
13
{
14
    use CollectorTrait;
15
16
    private array $assetBundles = [];
17
18
    public function getCollected(): array
19
    {
20
        return $this->assetBundles;
21
    }
22
23
    public function collect(AssetBundle $assetBundle): void
24
    {
25
        if (!$this->isActive()) {
26
            return;
27
        }
28
29
        $this->assetBundles[] = $assetBundle;
30
    }
31
32
    public function getIndexData(): array
33
    {
34
        return [
35
            'asset' => [
36
                'bundles' => [
37
                    'total' => count($this->assetBundles),
38
                ],
39
            ],
40
        ];
41
    }
42
43
    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...
44
    {
45
        $this->assetBundles = [];
46
    }
47
}
48