Passed
Pull Request — master (#118)
by Rustam
16:25
created

AssetCollector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 31
ccs 9
cts 10
cp 0.9
rs 10
wmc 5

4 Methods

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