AssetCollector   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 13
c 2
b 0
f 0
dl 0
loc 38
ccs 18
cts 18
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A reset() 0 3 1
A getCollected() 0 3 1
A getSummary() 0 10 2
A collect() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Assets\Debug;
6
7
use Yiisoft\Assets\AssetBundle;
8
use Yiisoft\Yii\Debug\Collector\CollectorTrait;
9
use Yiisoft\Yii\Debug\Collector\SummaryCollectorInterface;
10
11
use function count;
12
13
final class AssetCollector implements SummaryCollectorInterface
14
{
15
    use CollectorTrait;
16
17
    private array $assetBundles = [];
18
19 3
    public function getCollected(): array
20
    {
21 3
        return $this->assetBundles;
22
    }
23
24 2
    public function collect(AssetBundle $assetBundle): void
25
    {
26 2
        if (!$this->isActive()) {
27 1
            return;
28
        }
29
30 1
        $this->assetBundles[] = $assetBundle;
31
    }
32
33 3
    public function getSummary(): array
34
    {
35 3
        if (!$this->isActive()) {
36 2
            return [];
37
        }
38
39 1
        return [
40 1
            'asset' => [
41 1
                'bundles' => [
42 1
                    'total' => count($this->assetBundles),
43 1
                ],
44 1
            ],
45 1
        ];
46
    }
47
48 1
    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...
49
    {
50 1
        $this->assetBundles = [];
51
    }
52
}
53